-
Notifications
You must be signed in to change notification settings - Fork 0
/
socks4.c
39 lines (29 loc) · 830 Bytes
/
socks4.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
//
// Created by Administrator on 2023-10-05.
//
#include "socks4.h"
#include "util.h"
#include "socks.h"
#include "relay.h"
int socks4_read_id(int socket_fd, char *buf, int buf_len) {
readnull(socket_fd, buf, buf_len);
return 0;
}
int socks4_read_domain(int socket_fd, char *buf, int buf_len) {
int n = readnull(socket_fd, buf, buf_len);
if (n < 1) {
log_message("socks4_read_domain() less than %d byte read.", buf_len);
return -1;
}
return 0;
}
int socks4_is_4a(const char *ip) {
return (ip[0] == 0 && ip[1] == 0 && ip[2] == 0 && ip[3] != 0);
}
int socks4_send_response(int fd, int status) {
char response[8] = {0x00, (char) status, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
if (writen(fd, response, ARRAY_SIZE(response)) != 0) {
return -1;
}
return 0;
}