MINOR: proto: define dedicated protocol for active reverse connect
A new protocol named "reverse_connect" is created. This will be used to instantiate connections that are opened by a reverse bind. For the moment, only a minimal set of callbacks are defined with no real work. This will be extended along the next patches.
This commit is contained in:
parent
b57f151586
commit
5db6dde058
3
Makefile
3
Makefile
@ -947,7 +947,8 @@ OBJS += src/mux_h2.o src/mux_fcgi.o src/mux_h1.o src/tcpcheck.o \
|
||||
src/base64.o src/auth.o src/uri_auth.o src/time.o src/ebistree.o \
|
||||
src/dynbuf.o src/wdt.o src/pipe.o src/init.o src/http_acl.o \
|
||||
src/hpack-huff.o src/hpack-enc.o src/dict.o src/freq_ctr.o \
|
||||
src/ebtree.o src/hash.o src/dgram.o src/version.o
|
||||
src/ebtree.o src/hash.o src/dgram.o src/version.o \
|
||||
src/proto_reverse_connect.o
|
||||
|
||||
ifneq ($(TRACE),)
|
||||
OBJS += src/calltrace.o
|
||||
|
13
include/haproxy/proto_reverse_connect.h
Normal file
13
include/haproxy/proto_reverse_connect.h
Normal file
@ -0,0 +1,13 @@
|
||||
#ifndef _HAPROXY_PROTO_REVERSE_CONNECT_H
|
||||
#define _HAPROXY_PROTO_REVERSE_CONNECT_H
|
||||
|
||||
#include <haproxy/listener-t.h>
|
||||
#include <haproxy/receiver-t.h>
|
||||
|
||||
int rev_bind_receiver(struct receiver *rx, char **errmsg);
|
||||
|
||||
int rev_bind_listener(struct listener *listener, char *errmsg, int errlen);
|
||||
|
||||
int rev_accepting_conn(const struct receiver *rx);
|
||||
|
||||
#endif /* _HAPROXY_PROTO_REVERSE_CONNECT_H */
|
@ -39,7 +39,8 @@ struct connection;
|
||||
*/
|
||||
#define AF_CUST_EXISTING_FD (AF_MAX + 1)
|
||||
#define AF_CUST_SOCKPAIR (AF_MAX + 2)
|
||||
#define AF_CUST_MAX (AF_MAX + 3)
|
||||
#define AF_CUST_REV_SRV (AF_MAX + 3)
|
||||
#define AF_CUST_MAX (AF_MAX + 4)
|
||||
|
||||
/*
|
||||
* Test in case AF_CUST_MAX overflows the sa_family_t (unsigned int)
|
||||
|
49
src/proto_reverse_connect.c
Normal file
49
src/proto_reverse_connect.c
Normal file
@ -0,0 +1,49 @@
|
||||
#include <haproxy/api.h>
|
||||
#include <haproxy/errors.h>
|
||||
#include <haproxy/list.h>
|
||||
#include <haproxy/listener.h>
|
||||
#include <haproxy/protocol.h>
|
||||
|
||||
#include <haproxy/proto_reverse_connect.h>
|
||||
|
||||
struct proto_fam proto_fam_reverse_connect = {
|
||||
.name = "reverse_connect",
|
||||
.sock_domain = AF_CUST_REV_SRV,
|
||||
.sock_family = AF_INET,
|
||||
.bind = rev_bind_receiver,
|
||||
};
|
||||
|
||||
struct protocol proto_reverse_connect = {
|
||||
.name = "rev",
|
||||
|
||||
/* connection layer */
|
||||
.listen = rev_bind_listener,
|
||||
.add = default_add_listener,
|
||||
|
||||
/* address family */
|
||||
.fam = &proto_fam_reverse_connect,
|
||||
|
||||
/* socket layer */
|
||||
.proto_type = PROTO_TYPE_STREAM,
|
||||
.sock_type = SOCK_STREAM,
|
||||
.sock_prot = IPPROTO_TCP,
|
||||
.rx_listening = rev_accepting_conn,
|
||||
.receivers = LIST_HEAD_INIT(proto_reverse_connect.receivers),
|
||||
};
|
||||
|
||||
int rev_bind_receiver(struct receiver *rx, char **errmsg)
|
||||
{
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
int rev_bind_listener(struct listener *listener, char *errmsg, int errlen)
|
||||
{
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
int rev_accepting_conn(const struct receiver *rx)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
INITCALL1(STG_REGISTER, protocol_register, &proto_reverse_connect);
|
@ -1101,6 +1101,10 @@ struct sockaddr_storage *str2sa_range(const char *str, int *port, int *low, int
|
||||
str2 += 9;
|
||||
ss.ss_family = AF_CUST_SOCKPAIR;
|
||||
}
|
||||
else if (strncmp(str2, "rev@", 3) == 0) {
|
||||
str2 += 4;
|
||||
ss.ss_family = AF_CUST_REV_SRV;
|
||||
}
|
||||
else if (*str2 == '/') {
|
||||
ss.ss_family = AF_UNIX;
|
||||
}
|
||||
@ -1188,6 +1192,9 @@ struct sockaddr_storage *str2sa_range(const char *str, int *port, int *low, int
|
||||
memcpy(un->sun_path, pfx, prefix_path_len);
|
||||
memcpy(un->sun_path + prefix_path_len + abstract, str2, adr_len + 1 - abstract);
|
||||
}
|
||||
else if (ss.ss_family == AF_CUST_REV_SRV) {
|
||||
/* Nothing to do here. */
|
||||
}
|
||||
else { /* IPv4 and IPv6 */
|
||||
char *end = str2 + strlen(str2);
|
||||
char *chr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user