configurable port

This commit is contained in:
Quentin 2020-03-02 14:47:51 +01:00
parent 32ea58c36a
commit 9747457ce3
1 changed files with 21 additions and 3 deletions

View File

@ -137,7 +137,25 @@ error:
exit(EXIT_FAILURE);
}
int main(void) {
int main(int argc, char *argv[]) {
int opt = 0, port_socks5 = 9050, port_control = 9051;
char str_port_socks5[6], str_port_control[6];
while ((opt = getopt(argc, argv, "p:")) != -1) {
switch(opt) {
case 'p':
port_socks5 = atoi(optarg);
port_control = port_socks5+1;
break;
default:
break;
}
}
printf("ports socks5:%d control:%d\n", port_socks5, port_control);
sprintf(str_port_socks5, "%d", port_socks5);
sprintf(str_port_control, "%d", port_control);
struct evt_core_ctx evts = {0};
struct evt_core_cat socks5_listen = {
@ -246,7 +264,7 @@ int main(void) {
fdinfo.cat = &cat;
int err, sock = 0;
sock = create_tcp_server ("0.0.0.0", "9050");
sock = create_tcp_server ("0.0.0.0", str_port_socks5);
if (sock < 0) return EXIT_FAILURE;
err = listen(sock, SOMAXCONN);
if (err != 0) return EXIT_FAILURE;
@ -255,7 +273,7 @@ int main(void) {
fdinfo.url = "socks5:listen:9050";
evt_core_add_fd(&evts, &fdinfo);
sock = create_tcp_server ("0.0.0.0", "9051");
sock = create_tcp_server ("0.0.0.0", str_port_control);
if (sock < 0) return EXIT_FAILURE;
err = listen(sock, SOMAXCONN);
if (err != 0) return EXIT_FAILURE;