mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-10-31 22:45:45 +00:00
Fix UDP relay issue on Android
This commit is contained in:
+2
-4
@@ -399,9 +399,7 @@ aead_encrypt_all(buffer_t *plaintext, cipher_t *cipher, size_t capacity)
|
||||
ciphertext->len = tag_len + plaintext->len;
|
||||
|
||||
// generate nonce
|
||||
uint8_t nonce[MAX_NONCE_LENGTH];
|
||||
rand_bytes(nonce, nonce_len);
|
||||
|
||||
uint8_t *nonce = cipher_ctx.nonce;
|
||||
/* copy nonce to first pos */
|
||||
memcpy(ciphertext->data, nonce, nonce_len);
|
||||
|
||||
@@ -460,7 +458,7 @@ aead_decrypt_all(buffer_t *ciphertext, cipher_t *cipher, size_t capacity)
|
||||
plaintext->len = ciphertext->len - nonce_len - tag_len;
|
||||
|
||||
/* get nonce */
|
||||
uint8_t nonce[MAX_NONCE_LENGTH];
|
||||
uint8_t *nonce = cipher_ctx.nonce;
|
||||
memcpy(nonce, ciphertext->data, nonce_len);
|
||||
|
||||
size_t plen = plaintext->len;
|
||||
|
||||
@@ -675,9 +675,11 @@ server_recv_cb(EV_P_ ev_io *w, int revents)
|
||||
int err;
|
||||
struct sockaddr_storage storage;
|
||||
memset(&storage, 0, sizeof(struct sockaddr_storage));
|
||||
#ifndef ANDROID
|
||||
if (sni_detected || atyp == 3)
|
||||
err = get_sockaddr(host, port, &storage, 0, ipv6first);
|
||||
else
|
||||
#endif
|
||||
err = get_sockaddr(ip, port, &storage, 0, ipv6first);
|
||||
if (err != -1) {
|
||||
remote = create_remote(server->listener, (struct sockaddr *)&storage);
|
||||
|
||||
+2
-4
@@ -325,9 +325,7 @@ stream_encrypt_all(buffer_t *plaintext, cipher_t *cipher, size_t capacity)
|
||||
buffer_t *ciphertext = &tmp;
|
||||
ciphertext->len = plaintext->len;
|
||||
|
||||
uint8_t nonce[MAX_NONCE_LENGTH];
|
||||
|
||||
rand_bytes(nonce, nonce_len);
|
||||
uint8_t *nonce = cipher_ctx.nonce;
|
||||
cipher_ctx_set_nonce(&cipher_ctx, nonce, nonce_len, 1);
|
||||
memcpy(ciphertext->data, nonce, nonce_len);
|
||||
|
||||
@@ -449,7 +447,7 @@ stream_decrypt_all(buffer_t *ciphertext, cipher_t *cipher, size_t capacity)
|
||||
buffer_t *plaintext = &tmp;
|
||||
plaintext->len = ciphertext->len - nonce_len;
|
||||
|
||||
uint8_t nonce[MAX_NONCE_LENGTH];
|
||||
uint8_t *nonce = cipher_ctx.nonce;
|
||||
memcpy(nonce, ciphertext->data, nonce_len);
|
||||
cipher_ctx_set_nonce(&cipher_ctx, nonce, nonce_len, 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user