overmind 0.1.0-arm-freebsd
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/bin/overmind +13 -0
- data/lib/overmind/cli.rb +93 -0
- data/lib/overmind/version.rb +5 -0
- data/lib/overmind.rb +3 -0
- data/libexec/overmind +0 -0
- data/libexec/prebuilt-tmux/bin/event_rpcgen.py +1925 -0
- data/libexec/prebuilt-tmux/bin/tmux +0 -0
- data/libexec/prebuilt-tmux/include/evdns.h +45 -0
- data/libexec/prebuilt-tmux/include/event.h +83 -0
- data/libexec/prebuilt-tmux/include/event2/buffer.h +1077 -0
- data/libexec/prebuilt-tmux/include/event2/buffer_compat.h +116 -0
- data/libexec/prebuilt-tmux/include/event2/bufferevent.h +1024 -0
- data/libexec/prebuilt-tmux/include/event2/bufferevent_compat.h +104 -0
- data/libexec/prebuilt-tmux/include/event2/bufferevent_ssl.h +134 -0
- data/libexec/prebuilt-tmux/include/event2/bufferevent_struct.h +116 -0
- data/libexec/prebuilt-tmux/include/event2/dns.h +751 -0
- data/libexec/prebuilt-tmux/include/event2/dns_compat.h +358 -0
- data/libexec/prebuilt-tmux/include/event2/dns_struct.h +80 -0
- data/libexec/prebuilt-tmux/include/event2/event-config.h +570 -0
- data/libexec/prebuilt-tmux/include/event2/event.h +1672 -0
- data/libexec/prebuilt-tmux/include/event2/event_compat.h +230 -0
- data/libexec/prebuilt-tmux/include/event2/event_struct.h +180 -0
- data/libexec/prebuilt-tmux/include/event2/http.h +1192 -0
- data/libexec/prebuilt-tmux/include/event2/http_compat.h +94 -0
- data/libexec/prebuilt-tmux/include/event2/http_struct.h +152 -0
- data/libexec/prebuilt-tmux/include/event2/keyvalq_struct.h +80 -0
- data/libexec/prebuilt-tmux/include/event2/listener.h +192 -0
- data/libexec/prebuilt-tmux/include/event2/rpc.h +626 -0
- data/libexec/prebuilt-tmux/include/event2/rpc_compat.h +61 -0
- data/libexec/prebuilt-tmux/include/event2/rpc_struct.h +114 -0
- data/libexec/prebuilt-tmux/include/event2/tag.h +146 -0
- data/libexec/prebuilt-tmux/include/event2/tag_compat.h +49 -0
- data/libexec/prebuilt-tmux/include/event2/thread.h +253 -0
- data/libexec/prebuilt-tmux/include/event2/util.h +888 -0
- data/libexec/prebuilt-tmux/include/event2/visibility.h +67 -0
- data/libexec/prebuilt-tmux/include/evhttp.h +45 -0
- data/libexec/prebuilt-tmux/include/evrpc.h +45 -0
- data/libexec/prebuilt-tmux/include/evutil.h +39 -0
- data/libexec/prebuilt-tmux/include/utf8proc.h +743 -0
- data/libexec/prebuilt-tmux/lib/libevent-2.1.7.dylib +0 -0
- data/libexec/prebuilt-tmux/lib/libevent.a +0 -0
- data/libexec/prebuilt-tmux/lib/libevent.dylib +1 -0
- data/libexec/prebuilt-tmux/lib/libevent.la +41 -0
- data/libexec/prebuilt-tmux/lib/libevent_core-2.1.7.dylib +0 -0
- data/libexec/prebuilt-tmux/lib/libevent_core.a +0 -0
- data/libexec/prebuilt-tmux/lib/libevent_core.dylib +1 -0
- data/libexec/prebuilt-tmux/lib/libevent_core.la +41 -0
- data/libexec/prebuilt-tmux/lib/libevent_extra-2.1.7.dylib +0 -0
- data/libexec/prebuilt-tmux/lib/libevent_extra.a +0 -0
- data/libexec/prebuilt-tmux/lib/libevent_extra.dylib +1 -0
- data/libexec/prebuilt-tmux/lib/libevent_extra.la +41 -0
- data/libexec/prebuilt-tmux/lib/libevent_openssl-2.1.7.dylib +0 -0
- data/libexec/prebuilt-tmux/lib/libevent_openssl.a +0 -0
- data/libexec/prebuilt-tmux/lib/libevent_openssl.dylib +1 -0
- data/libexec/prebuilt-tmux/lib/libevent_openssl.la +41 -0
- data/libexec/prebuilt-tmux/lib/libevent_pthreads-2.1.7.dylib +0 -0
- data/libexec/prebuilt-tmux/lib/libevent_pthreads.a +0 -0
- data/libexec/prebuilt-tmux/lib/libevent_pthreads.dylib +1 -0
- data/libexec/prebuilt-tmux/lib/libevent_pthreads.la +41 -0
- data/libexec/prebuilt-tmux/lib/libutf8proc.3.dylib +0 -0
- data/libexec/prebuilt-tmux/lib/libutf8proc.a +0 -0
- data/libexec/prebuilt-tmux/lib/libutf8proc.dylib +1 -0
- data/libexec/prebuilt-tmux/lib/pkgconfig/libevent.pc +16 -0
- data/libexec/prebuilt-tmux/lib/pkgconfig/libevent_core.pc +16 -0
- data/libexec/prebuilt-tmux/lib/pkgconfig/libevent_extra.pc +16 -0
- data/libexec/prebuilt-tmux/lib/pkgconfig/libevent_openssl.pc +16 -0
- data/libexec/prebuilt-tmux/lib/pkgconfig/libevent_pthreads.pc +16 -0
- data/libexec/prebuilt-tmux/lib/pkgconfig/libutf8proc.pc +10 -0
- data/libexec/prebuilt-tmux/share/man/man1/tmux.1 +7242 -0
- data/overmind.gemspec +29 -0
- metadata +160 -0
@@ -0,0 +1,94 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2000-2007 Niels Provos <provos@citi.umich.edu>
|
3
|
+
* Copyright (c) 2007-2012 Niels Provos and Nick Mathewson
|
4
|
+
*
|
5
|
+
* Redistribution and use in source and binary forms, with or without
|
6
|
+
* modification, are permitted provided that the following conditions
|
7
|
+
* are met:
|
8
|
+
* 1. Redistributions of source code must retain the above copyright
|
9
|
+
* notice, this list of conditions and the following disclaimer.
|
10
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
11
|
+
* notice, this list of conditions and the following disclaimer in the
|
12
|
+
* documentation and/or other materials provided with the distribution.
|
13
|
+
* 3. The name of the author may not be used to endorse or promote products
|
14
|
+
* derived from this software without specific prior written permission.
|
15
|
+
*
|
16
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
17
|
+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
18
|
+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
19
|
+
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
20
|
+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
21
|
+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
22
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
23
|
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
24
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
25
|
+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
26
|
+
*/
|
27
|
+
#ifndef EVENT2_HTTP_COMPAT_H_INCLUDED_
|
28
|
+
#define EVENT2_HTTP_COMPAT_H_INCLUDED_
|
29
|
+
|
30
|
+
/** @file event2/http_compat.h
|
31
|
+
|
32
|
+
Potentially non-threadsafe versions of the functions in http.h: provided
|
33
|
+
only for backwards compatibility.
|
34
|
+
|
35
|
+
*/
|
36
|
+
|
37
|
+
#ifdef __cplusplus
|
38
|
+
extern "C" {
|
39
|
+
#endif
|
40
|
+
|
41
|
+
#include <event2/event-config.h>
|
42
|
+
#ifdef EVENT__HAVE_SYS_TYPES_H
|
43
|
+
#include <sys/types.h>
|
44
|
+
#endif
|
45
|
+
#ifdef EVENT__HAVE_SYS_TIME_H
|
46
|
+
#include <sys/time.h>
|
47
|
+
#endif
|
48
|
+
|
49
|
+
/* For int types. */
|
50
|
+
#include <event2/util.h>
|
51
|
+
|
52
|
+
/**
|
53
|
+
* Start an HTTP server on the specified address and port
|
54
|
+
*
|
55
|
+
* @deprecated It does not allow an event base to be specified
|
56
|
+
*
|
57
|
+
* @param address the address to which the HTTP server should be bound
|
58
|
+
* @param port the port number on which the HTTP server should listen
|
59
|
+
* @return a pointer to a newly initialized evhttp server structure
|
60
|
+
* or NULL on error
|
61
|
+
*/
|
62
|
+
EVENT2_EXPORT_SYMBOL
|
63
|
+
struct evhttp *evhttp_start(const char *address, ev_uint16_t port);
|
64
|
+
|
65
|
+
/**
|
66
|
+
* A connection object that can be used to for making HTTP requests. The
|
67
|
+
* connection object tries to establish the connection when it is given an
|
68
|
+
* http request object.
|
69
|
+
*
|
70
|
+
* @deprecated It does not allow an event base to be specified
|
71
|
+
*/
|
72
|
+
EVENT2_EXPORT_SYMBOL
|
73
|
+
struct evhttp_connection *evhttp_connection_new(
|
74
|
+
const char *address, ev_uint16_t port);
|
75
|
+
|
76
|
+
/**
|
77
|
+
* Associates an event base with the connection - can only be called
|
78
|
+
* on a freshly created connection object that has not been used yet.
|
79
|
+
*
|
80
|
+
* @deprecated XXXX Why?
|
81
|
+
*/
|
82
|
+
EVENT2_EXPORT_SYMBOL
|
83
|
+
void evhttp_connection_set_base(struct evhttp_connection *evcon,
|
84
|
+
struct event_base *base);
|
85
|
+
|
86
|
+
|
87
|
+
/** Returns the request URI */
|
88
|
+
#define evhttp_request_uri evhttp_request_get_uri
|
89
|
+
|
90
|
+
#ifdef __cplusplus
|
91
|
+
}
|
92
|
+
#endif
|
93
|
+
|
94
|
+
#endif /* EVENT2_EVENT_COMPAT_H_INCLUDED_ */
|
@@ -0,0 +1,152 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2000-2007 Niels Provos <provos@citi.umich.edu>
|
3
|
+
* Copyright (c) 2007-2012 Niels Provos and Nick Mathewson
|
4
|
+
*
|
5
|
+
* Redistribution and use in source and binary forms, with or without
|
6
|
+
* modification, are permitted provided that the following conditions
|
7
|
+
* are met:
|
8
|
+
* 1. Redistributions of source code must retain the above copyright
|
9
|
+
* notice, this list of conditions and the following disclaimer.
|
10
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
11
|
+
* notice, this list of conditions and the following disclaimer in the
|
12
|
+
* documentation and/or other materials provided with the distribution.
|
13
|
+
* 3. The name of the author may not be used to endorse or promote products
|
14
|
+
* derived from this software without specific prior written permission.
|
15
|
+
*
|
16
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
17
|
+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
18
|
+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
19
|
+
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
20
|
+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
21
|
+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
22
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
23
|
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
24
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
25
|
+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
26
|
+
*/
|
27
|
+
#ifndef EVENT2_HTTP_STRUCT_H_INCLUDED_
|
28
|
+
#define EVENT2_HTTP_STRUCT_H_INCLUDED_
|
29
|
+
|
30
|
+
/** @file event2/http_struct.h
|
31
|
+
|
32
|
+
Data structures for http. Using these structures may hurt forward
|
33
|
+
compatibility with later versions of Libevent: be careful!
|
34
|
+
|
35
|
+
*/
|
36
|
+
|
37
|
+
#ifdef __cplusplus
|
38
|
+
extern "C" {
|
39
|
+
#endif
|
40
|
+
|
41
|
+
#include <event2/event-config.h>
|
42
|
+
#ifdef EVENT__HAVE_SYS_TYPES_H
|
43
|
+
#include <sys/types.h>
|
44
|
+
#endif
|
45
|
+
#ifdef EVENT__HAVE_SYS_TIME_H
|
46
|
+
#include <sys/time.h>
|
47
|
+
#endif
|
48
|
+
|
49
|
+
/* For int types. */
|
50
|
+
#include <event2/util.h>
|
51
|
+
|
52
|
+
/**
|
53
|
+
* the request structure that a server receives.
|
54
|
+
* WARNING: expect this structure to change. I will try to provide
|
55
|
+
* reasonable accessors.
|
56
|
+
*/
|
57
|
+
struct evhttp_request {
|
58
|
+
#if defined(TAILQ_ENTRY)
|
59
|
+
TAILQ_ENTRY(evhttp_request) next;
|
60
|
+
#else
|
61
|
+
struct {
|
62
|
+
struct evhttp_request *tqe_next;
|
63
|
+
struct evhttp_request **tqe_prev;
|
64
|
+
} next;
|
65
|
+
#endif
|
66
|
+
|
67
|
+
/* the connection object that this request belongs to */
|
68
|
+
struct evhttp_connection *evcon;
|
69
|
+
int flags;
|
70
|
+
/** The request obj owns the evhttp connection and needs to free it */
|
71
|
+
#define EVHTTP_REQ_OWN_CONNECTION 0x0001
|
72
|
+
/** Request was made via a proxy */
|
73
|
+
#define EVHTTP_PROXY_REQUEST 0x0002
|
74
|
+
/** The request object is owned by the user; the user must free it */
|
75
|
+
#define EVHTTP_USER_OWNED 0x0004
|
76
|
+
/** The request will be used again upstack; freeing must be deferred */
|
77
|
+
#define EVHTTP_REQ_DEFER_FREE 0x0008
|
78
|
+
/** The request should be freed upstack */
|
79
|
+
#define EVHTTP_REQ_NEEDS_FREE 0x0010
|
80
|
+
|
81
|
+
struct evkeyvalq *input_headers;
|
82
|
+
struct evkeyvalq *output_headers;
|
83
|
+
|
84
|
+
/* address of the remote host and the port connection came from */
|
85
|
+
char *remote_host;
|
86
|
+
ev_uint16_t remote_port;
|
87
|
+
|
88
|
+
/* cache of the hostname for evhttp_request_get_host */
|
89
|
+
char *host_cache;
|
90
|
+
|
91
|
+
enum evhttp_request_kind kind;
|
92
|
+
enum evhttp_cmd_type type;
|
93
|
+
|
94
|
+
size_t headers_size;
|
95
|
+
size_t body_size;
|
96
|
+
|
97
|
+
char *uri; /* uri after HTTP request was parsed */
|
98
|
+
struct evhttp_uri *uri_elems; /* uri elements */
|
99
|
+
|
100
|
+
char major; /* HTTP Major number */
|
101
|
+
char minor; /* HTTP Minor number */
|
102
|
+
|
103
|
+
int response_code; /* HTTP Response code */
|
104
|
+
char *response_code_line; /* Readable response */
|
105
|
+
|
106
|
+
struct evbuffer *input_buffer; /* read data */
|
107
|
+
ev_int64_t ntoread;
|
108
|
+
unsigned chunked:1, /* a chunked request */
|
109
|
+
userdone:1; /* the user has sent all data */
|
110
|
+
|
111
|
+
struct evbuffer *output_buffer; /* outgoing post or data */
|
112
|
+
|
113
|
+
/* Callback */
|
114
|
+
void (*cb)(struct evhttp_request *, void *);
|
115
|
+
void *cb_arg;
|
116
|
+
|
117
|
+
/*
|
118
|
+
* Chunked data callback - call for each completed chunk if
|
119
|
+
* specified. If not specified, all the data is delivered via
|
120
|
+
* the regular callback.
|
121
|
+
*/
|
122
|
+
void (*chunk_cb)(struct evhttp_request *, void *);
|
123
|
+
|
124
|
+
/*
|
125
|
+
* Callback added for forked-daapd so they can collect ICY
|
126
|
+
* (shoutcast) metadata from the http header. If return
|
127
|
+
* int is negative the connection will be closed.
|
128
|
+
*/
|
129
|
+
int (*header_cb)(struct evhttp_request *, void *);
|
130
|
+
|
131
|
+
/*
|
132
|
+
* Error callback - called when error is occured.
|
133
|
+
* @see evhttp_request_error for error types.
|
134
|
+
*
|
135
|
+
* @see evhttp_request_set_error_cb()
|
136
|
+
*/
|
137
|
+
void (*error_cb)(enum evhttp_request_error, void *);
|
138
|
+
|
139
|
+
/*
|
140
|
+
* Send complete callback - called when the request is actually
|
141
|
+
* sent and completed.
|
142
|
+
*/
|
143
|
+
void (*on_complete_cb)(struct evhttp_request *, void *);
|
144
|
+
void *on_complete_cb_arg;
|
145
|
+
};
|
146
|
+
|
147
|
+
#ifdef __cplusplus
|
148
|
+
}
|
149
|
+
#endif
|
150
|
+
|
151
|
+
#endif /* EVENT2_HTTP_STRUCT_H_INCLUDED_ */
|
152
|
+
|
@@ -0,0 +1,80 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2000-2007 Niels Provos <provos@citi.umich.edu>
|
3
|
+
* Copyright (c) 2007-2012 Niels Provos and Nick Mathewson
|
4
|
+
*
|
5
|
+
* Redistribution and use in source and binary forms, with or without
|
6
|
+
* modification, are permitted provided that the following conditions
|
7
|
+
* are met:
|
8
|
+
* 1. Redistributions of source code must retain the above copyright
|
9
|
+
* notice, this list of conditions and the following disclaimer.
|
10
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
11
|
+
* notice, this list of conditions and the following disclaimer in the
|
12
|
+
* documentation and/or other materials provided with the distribution.
|
13
|
+
* 3. The name of the author may not be used to endorse or promote products
|
14
|
+
* derived from this software without specific prior written permission.
|
15
|
+
*
|
16
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
17
|
+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
18
|
+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
19
|
+
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
20
|
+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
21
|
+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
22
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
23
|
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
24
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
25
|
+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
26
|
+
*/
|
27
|
+
#ifndef EVENT2_KEYVALQ_STRUCT_H_INCLUDED_
|
28
|
+
#define EVENT2_KEYVALQ_STRUCT_H_INCLUDED_
|
29
|
+
|
30
|
+
#ifdef __cplusplus
|
31
|
+
extern "C" {
|
32
|
+
#endif
|
33
|
+
|
34
|
+
/* Fix so that people don't have to run with <sys/queue.h> */
|
35
|
+
/* XXXX This code is duplicated with event_struct.h */
|
36
|
+
#ifndef TAILQ_ENTRY
|
37
|
+
#define EVENT_DEFINED_TQENTRY_
|
38
|
+
#define TAILQ_ENTRY(type) \
|
39
|
+
struct { \
|
40
|
+
struct type *tqe_next; /* next element */ \
|
41
|
+
struct type **tqe_prev; /* address of previous next element */ \
|
42
|
+
}
|
43
|
+
#endif /* !TAILQ_ENTRY */
|
44
|
+
|
45
|
+
#ifndef TAILQ_HEAD
|
46
|
+
#define EVENT_DEFINED_TQHEAD_
|
47
|
+
#define TAILQ_HEAD(name, type) \
|
48
|
+
struct name { \
|
49
|
+
struct type *tqh_first; \
|
50
|
+
struct type **tqh_last; \
|
51
|
+
}
|
52
|
+
#endif
|
53
|
+
|
54
|
+
/*
|
55
|
+
* Key-Value pairs. Can be used for HTTP headers but also for
|
56
|
+
* query argument parsing.
|
57
|
+
*/
|
58
|
+
struct evkeyval {
|
59
|
+
TAILQ_ENTRY(evkeyval) next;
|
60
|
+
|
61
|
+
char *key;
|
62
|
+
char *value;
|
63
|
+
};
|
64
|
+
|
65
|
+
TAILQ_HEAD (evkeyvalq, evkeyval);
|
66
|
+
|
67
|
+
/* XXXX This code is duplicated with event_struct.h */
|
68
|
+
#ifdef EVENT_DEFINED_TQENTRY_
|
69
|
+
#undef TAILQ_ENTRY
|
70
|
+
#endif
|
71
|
+
|
72
|
+
#ifdef EVENT_DEFINED_TQHEAD_
|
73
|
+
#undef TAILQ_HEAD
|
74
|
+
#endif
|
75
|
+
|
76
|
+
#ifdef __cplusplus
|
77
|
+
}
|
78
|
+
#endif
|
79
|
+
|
80
|
+
#endif
|
@@ -0,0 +1,192 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2000-2007 Niels Provos <provos@citi.umich.edu>
|
3
|
+
* Copyright (c) 2007-2012 Niels Provos and Nick Mathewson
|
4
|
+
*
|
5
|
+
* Redistribution and use in source and binary forms, with or without
|
6
|
+
* modification, are permitted provided that the following conditions
|
7
|
+
* are met:
|
8
|
+
* 1. Redistributions of source code must retain the above copyright
|
9
|
+
* notice, this list of conditions and the following disclaimer.
|
10
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
11
|
+
* notice, this list of conditions and the following disclaimer in the
|
12
|
+
* documentation and/or other materials provided with the distribution.
|
13
|
+
* 3. The name of the author may not be used to endorse or promote products
|
14
|
+
* derived from this software without specific prior written permission.
|
15
|
+
*
|
16
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
17
|
+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
18
|
+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
19
|
+
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
20
|
+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
21
|
+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
22
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
23
|
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
24
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
25
|
+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
26
|
+
*/
|
27
|
+
#ifndef EVENT2_LISTENER_H_INCLUDED_
|
28
|
+
#define EVENT2_LISTENER_H_INCLUDED_
|
29
|
+
|
30
|
+
#include <event2/visibility.h>
|
31
|
+
|
32
|
+
#ifdef __cplusplus
|
33
|
+
extern "C" {
|
34
|
+
#endif
|
35
|
+
|
36
|
+
#include <event2/event.h>
|
37
|
+
|
38
|
+
struct sockaddr;
|
39
|
+
struct evconnlistener;
|
40
|
+
|
41
|
+
/**
|
42
|
+
A callback that we invoke when a listener has a new connection.
|
43
|
+
|
44
|
+
@param listener The evconnlistener
|
45
|
+
@param fd The new file descriptor
|
46
|
+
@param addr The source address of the connection
|
47
|
+
@param socklen The length of addr
|
48
|
+
@param user_arg the pointer passed to evconnlistener_new()
|
49
|
+
*/
|
50
|
+
typedef void (*evconnlistener_cb)(struct evconnlistener *, evutil_socket_t, struct sockaddr *, int socklen, void *);
|
51
|
+
|
52
|
+
/**
|
53
|
+
A callback that we invoke when a listener encounters a non-retriable error.
|
54
|
+
|
55
|
+
@param listener The evconnlistener
|
56
|
+
@param user_arg the pointer passed to evconnlistener_new()
|
57
|
+
*/
|
58
|
+
typedef void (*evconnlistener_errorcb)(struct evconnlistener *, void *);
|
59
|
+
|
60
|
+
/** Flag: Indicates that we should not make incoming sockets nonblocking
|
61
|
+
* before passing them to the callback. */
|
62
|
+
#define LEV_OPT_LEAVE_SOCKETS_BLOCKING (1u<<0)
|
63
|
+
/** Flag: Indicates that freeing the listener should close the underlying
|
64
|
+
* socket. */
|
65
|
+
#define LEV_OPT_CLOSE_ON_FREE (1u<<1)
|
66
|
+
/** Flag: Indicates that we should set the close-on-exec flag, if possible */
|
67
|
+
#define LEV_OPT_CLOSE_ON_EXEC (1u<<2)
|
68
|
+
/** Flag: Indicates that we should disable the timeout (if any) between when
|
69
|
+
* this socket is closed and when we can listen again on the same port. */
|
70
|
+
#define LEV_OPT_REUSEABLE (1u<<3)
|
71
|
+
/** Flag: Indicates that the listener should be locked so it's safe to use
|
72
|
+
* from multiple threadcs at once. */
|
73
|
+
#define LEV_OPT_THREADSAFE (1u<<4)
|
74
|
+
/** Flag: Indicates that the listener should be created in disabled
|
75
|
+
* state. Use evconnlistener_enable() to enable it later. */
|
76
|
+
#define LEV_OPT_DISABLED (1u<<5)
|
77
|
+
/** Flag: Indicates that the listener should defer accept() until data is
|
78
|
+
* available, if possible. Ignored on platforms that do not support this.
|
79
|
+
*
|
80
|
+
* This option can help performance for protocols where the client transmits
|
81
|
+
* immediately after connecting. Do not use this option if your protocol
|
82
|
+
* _doesn't_ start out with the client transmitting data, since in that case
|
83
|
+
* this option will sometimes cause the kernel to never tell you about the
|
84
|
+
* connection.
|
85
|
+
*
|
86
|
+
* This option is only supported by evconnlistener_new_bind(): it can't
|
87
|
+
* work with evconnlistener_new_fd(), since the listener needs to be told
|
88
|
+
* to use the option before it is actually bound.
|
89
|
+
*/
|
90
|
+
#define LEV_OPT_DEFERRED_ACCEPT (1u<<6)
|
91
|
+
/** Flag: Indicates that we ask to allow multiple servers (processes or
|
92
|
+
* threads) to bind to the same port if they each set the option.
|
93
|
+
*
|
94
|
+
* SO_REUSEPORT is what most people would expect SO_REUSEADDR to be, however
|
95
|
+
* SO_REUSEPORT does not imply SO_REUSEADDR.
|
96
|
+
*
|
97
|
+
* This is only available on Linux and kernel 3.9+
|
98
|
+
*/
|
99
|
+
#define LEV_OPT_REUSEABLE_PORT (1u<<7)
|
100
|
+
/** Flag: Indicates that the listener wants to work only in IPv6 socket.
|
101
|
+
*
|
102
|
+
* According to RFC3493 and most Linux distributions, default value is to
|
103
|
+
* work in IPv4-mapped mode. If there is a requirement to bind same port
|
104
|
+
* on same ip addresses but different handlers for both IPv4 and IPv6,
|
105
|
+
* it is required to set IPV6_V6ONLY socket option to be sure that the
|
106
|
+
* code works as expected without affected by bindv6only sysctl setting in
|
107
|
+
* system.
|
108
|
+
*
|
109
|
+
* This socket option also supported by Windows.
|
110
|
+
*/
|
111
|
+
#define LEV_OPT_BIND_IPV6ONLY (1u<<8)
|
112
|
+
|
113
|
+
/**
|
114
|
+
Allocate a new evconnlistener object to listen for incoming TCP connections
|
115
|
+
on a given file descriptor.
|
116
|
+
|
117
|
+
@param base The event base to associate the listener with.
|
118
|
+
@param cb A callback to be invoked when a new connection arrives. If the
|
119
|
+
callback is NULL, the listener will be treated as disabled until the
|
120
|
+
callback is set.
|
121
|
+
@param ptr A user-supplied pointer to give to the callback.
|
122
|
+
@param flags Any number of LEV_OPT_* flags
|
123
|
+
@param backlog Passed to the listen() call to determine the length of the
|
124
|
+
acceptable connection backlog. Set to -1 for a reasonable default.
|
125
|
+
Set to 0 if the socket is already listening.
|
126
|
+
@param fd The file descriptor to listen on. It must be a nonblocking
|
127
|
+
file descriptor, and it should already be bound to an appropriate
|
128
|
+
port and address.
|
129
|
+
*/
|
130
|
+
EVENT2_EXPORT_SYMBOL
|
131
|
+
struct evconnlistener *evconnlistener_new(struct event_base *base,
|
132
|
+
evconnlistener_cb cb, void *ptr, unsigned flags, int backlog,
|
133
|
+
evutil_socket_t fd);
|
134
|
+
/**
|
135
|
+
Allocate a new evconnlistener object to listen for incoming TCP connections
|
136
|
+
on a given address.
|
137
|
+
|
138
|
+
@param base The event base to associate the listener with.
|
139
|
+
@param cb A callback to be invoked when a new connection arrives. If the
|
140
|
+
callback is NULL, the listener will be treated as disabled until the
|
141
|
+
callback is set.
|
142
|
+
@param ptr A user-supplied pointer to give to the callback.
|
143
|
+
@param flags Any number of LEV_OPT_* flags
|
144
|
+
@param backlog Passed to the listen() call to determine the length of the
|
145
|
+
acceptable connection backlog. Set to -1 for a reasonable default.
|
146
|
+
@param addr The address to listen for connections on.
|
147
|
+
@param socklen The length of the address.
|
148
|
+
*/
|
149
|
+
EVENT2_EXPORT_SYMBOL
|
150
|
+
struct evconnlistener *evconnlistener_new_bind(struct event_base *base,
|
151
|
+
evconnlistener_cb cb, void *ptr, unsigned flags, int backlog,
|
152
|
+
const struct sockaddr *sa, int socklen);
|
153
|
+
/**
|
154
|
+
Disable and deallocate an evconnlistener.
|
155
|
+
*/
|
156
|
+
EVENT2_EXPORT_SYMBOL
|
157
|
+
void evconnlistener_free(struct evconnlistener *lev);
|
158
|
+
/**
|
159
|
+
Re-enable an evconnlistener that has been disabled.
|
160
|
+
*/
|
161
|
+
EVENT2_EXPORT_SYMBOL
|
162
|
+
int evconnlistener_enable(struct evconnlistener *lev);
|
163
|
+
/**
|
164
|
+
Stop listening for connections on an evconnlistener.
|
165
|
+
*/
|
166
|
+
EVENT2_EXPORT_SYMBOL
|
167
|
+
int evconnlistener_disable(struct evconnlistener *lev);
|
168
|
+
|
169
|
+
/** Return an evconnlistener's associated event_base. */
|
170
|
+
EVENT2_EXPORT_SYMBOL
|
171
|
+
struct event_base *evconnlistener_get_base(struct evconnlistener *lev);
|
172
|
+
|
173
|
+
/** Return the socket that an evconnlistner is listening on. */
|
174
|
+
EVENT2_EXPORT_SYMBOL
|
175
|
+
evutil_socket_t evconnlistener_get_fd(struct evconnlistener *lev);
|
176
|
+
|
177
|
+
/** Change the callback on the listener to cb and its user_data to arg.
|
178
|
+
*/
|
179
|
+
EVENT2_EXPORT_SYMBOL
|
180
|
+
void evconnlistener_set_cb(struct evconnlistener *lev,
|
181
|
+
evconnlistener_cb cb, void *arg);
|
182
|
+
|
183
|
+
/** Set an evconnlistener's error callback. */
|
184
|
+
EVENT2_EXPORT_SYMBOL
|
185
|
+
void evconnlistener_set_error_cb(struct evconnlistener *lev,
|
186
|
+
evconnlistener_errorcb errorcb);
|
187
|
+
|
188
|
+
#ifdef __cplusplus
|
189
|
+
}
|
190
|
+
#endif
|
191
|
+
|
192
|
+
#endif
|