1 /*
2  * jconf.h - Define the config data structure
3  *
4  * Copyright (C) 2013 - 2019, Max Lv <max.c.lv@gmail.com>
5  *
6  * This file is part of the shadowsocks-libev.
7  * shadowsocks-libev is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * shadowsocks-libev is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with shadowsocks-libev; see the file COPYING. If not, see
19  * <http://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef _JCONF_H
23 #define _JCONF_H
24 
25 #define MAX_PORT_NUM 1024
26 #define MAX_REMOTE_NUM 10
27 #define MAX_DSCP_NUM 64
28 #define MAX_CONF_SIZE (128 * 1024)
29 #define MAX_CONNECT_TIMEOUT 10
30 #define MIN_TCP_IDLE_TIMEOUT (24 * 3600)
31 #define MIN_UDP_TIMEOUT 10
32 
33 #define DSCP_EF      0x2E
34 #define DSCP_MIN     0x0
35 #define DSCP_MAX     0x3F
36 #define DSCP_DEFAULT 0x0
37 #define DSCP_MIN_LEN 2
38 #define DSCP_MAX_LEN 4
39 #define DSCP_CS_LEN  3
40 #define DSCP_AF_LEN  4
41 
42 #define TCP_ONLY     0
43 #define TCP_AND_UDP  1
44 #define UDP_ONLY     3
45 
46 typedef struct {
47     char *port;
48     char *password;
49 } ss_port_password_t;
50 
51 typedef struct {
52     char *port;
53     int dscp;
54 } ss_dscp_t;
55 
56 typedef struct {
57     int remote_num;
58     ss_addr_t remote_addr[MAX_REMOTE_NUM];
59     int port_password_num;
60     ss_port_password_t port_password[MAX_PORT_NUM];
61     char *remote_port;
62     char *local_addr;
63     char *local_addr_v4;
64     char *local_addr_v6;
65     char *local_port;
66     char *password;
67     char *key;
68     char *method;
69     char *timeout;
70     char *user;
71     char *plugin;
72     char *plugin_opts;
73     int fast_open;
74     int reuse_port;
75     int nofile;
76     char *nameserver;
77     int dscp_num;
78     ss_dscp_t dscp[MAX_DSCP_NUM];
79     char *tunnel_address;
80     int mode;
81     int mtu;
82     int mptcp;
83     int ipv6_first;
84     int no_delay;
85     int tcp_tproxy;
86     char *workdir;
87     char *acl;
88     char *manager_address;
89 } jconf_t;
90 
91 jconf_t *read_jconf(const char *file);
92 void parse_addr(const char *str, ss_addr_t *addr);
93 void free_addr(ss_addr_t *addr);
94 
95 #endif // _JCONF_H
96