mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-10-30 13:13:44 +00:00
add onetime authentication
This commit is contained in:
+16
-1
@@ -109,6 +109,7 @@ int verbose = 0;
|
||||
|
||||
static int acl = 0;
|
||||
static int mode = TCP_ONLY;
|
||||
static int auth = 0;
|
||||
|
||||
static int fast_open = 0;
|
||||
#ifdef HAVE_SETRLIMIT
|
||||
@@ -639,6 +640,16 @@ static void server_recv_cb(EV_P_ ev_io *w, int revents)
|
||||
|
||||
offset += 2;
|
||||
|
||||
if (auth) {
|
||||
if (ss_onetimeauth_verify(server->buf + offset, server->buf, offset)) {
|
||||
LOGE("authentication error %d", atyp);
|
||||
report_addr(server->fd);
|
||||
close_and_free_server(EV_A_ server);
|
||||
return;
|
||||
};
|
||||
offset += ONETIMEAUTH_BYTES;
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
LOGI("connect to: %s:%d", host, ntohs(port));
|
||||
}
|
||||
@@ -1193,7 +1204,7 @@ int main(int argc, char **argv)
|
||||
|
||||
USE_TTY();
|
||||
|
||||
while ((c = getopt_long(argc, argv, "f:s:p:l:k:t:m:c:i:d:a:uUv",
|
||||
while ((c = getopt_long(argc, argv, "f:s:p:l:k:t:m:c:i:d:a:uUvA",
|
||||
long_options, &option_index)) != -1) {
|
||||
switch (c) {
|
||||
case 0:
|
||||
@@ -1250,6 +1261,10 @@ int main(int argc, char **argv)
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
break;
|
||||
case 'A':
|
||||
auth = 1;
|
||||
LOGI("onetime authentication enabled");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user