-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsocks5_no_auth_authenticator.c
43 lines (36 loc) · 1.26 KB
/
socks5_no_auth_authenticator.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <event2/buffer.h>
#include <event2/bufferevent.h>
#include "socks5_protocol.h"
#include "socks5_no_auth_authenticator.h"
static int no_auth_authenticate(struct authenticator *authenticator);
static int no_auth_poll_input(struct authenticator *authenticator);
static int no_auth_flush_output(struct authenticator *authenticator);
static void no_auth_inner_free(void *inner);
struct authenticator *no_auth_authenticator_new(struct bufferevent *underlying_bev)
{
struct authenticator_imp imp = {
no_auth_authenticate,
no_auth_poll_input,
no_auth_flush_output,
no_auth_inner_free,
};
return authenticator_new(SOCKS5_AUTH_METHOD_NO_AUTH_REQUIRED, imp, NULL/*inner*/, underlying_bev);
}
static int no_auth_authenticate(struct authenticator *authenticator)
{
(void)authenticator;
return YM_AUTH_SUCCESS;
}
static int no_auth_poll_input(struct authenticator *authenticator)
{
return bufferevent_read_buffer(authenticator->underlying_bev, authenticator->input);
}
static int no_auth_flush_output(struct authenticator *authenticator)
{
return bufferevent_write_buffer(authenticator->underlying_bev, authenticator->output);
}
static void no_auth_inner_free(void *inner)
{
(void)inner;
return; /* nothing to do */
}