Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c31106689a | ||
|
|
ce522f5675 | ||
|
|
6bd859747a | ||
|
|
7d5f53aebb | ||
|
|
f28efdf2b1 | ||
|
|
a9a75c6554 | ||
|
|
26f49d26db | ||
|
|
508ddd60e0 | ||
|
|
08b908273a | ||
|
|
8402967a0e | ||
|
|
a2e4264b01 | ||
|
|
ce057a05a7 | ||
|
|
7515c15123 | ||
|
|
60871860ae | ||
|
|
f8d065b09e | ||
|
|
2f2e64ae31 | ||
|
|
a4812dd596 | ||
|
|
2e420e921c | ||
|
|
99972f257a | ||
|
|
8e4ca75d36 | ||
|
|
360019d1a4 | ||
|
|
204c086a03 | ||
|
|
316834ffd0 | ||
|
|
aefbd2e062 | ||
|
|
ff6f60f079 |
45
client.c
45
client.c
@@ -54,14 +54,14 @@
|
||||
#include "zip.h"
|
||||
#include "common.h"
|
||||
#include "proxy.h"
|
||||
#include "utils.h"
|
||||
|
||||
#define MAX_OUTPUT (512*1024)
|
||||
|
||||
static void drained_writecb(struct bufferevent *bev, void *ctx);
|
||||
static void xfrp_event_cb(struct bufferevent *bev, short what, void *ctx);
|
||||
|
||||
static void
|
||||
xfrp_read_cb(struct bufferevent *bev, void *ctx)
|
||||
static void xfrp_read_cb(struct bufferevent *bev, void *ctx)
|
||||
{
|
||||
struct proxy *p = (struct proxy *)ctx;
|
||||
struct bufferevent *partner = p?p->bev:NULL;
|
||||
@@ -89,8 +89,7 @@ xfrp_read_cb(struct bufferevent *bev, void *ctx)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
drained_writecb(struct bufferevent *bev, void *ctx)
|
||||
static void drained_writecb(struct bufferevent *bev, void *ctx)
|
||||
{
|
||||
struct proxy *p = (struct proxy *)ctx;
|
||||
struct bufferevent *partner = p?p->bev:NULL;
|
||||
@@ -103,8 +102,7 @@ drained_writecb(struct bufferevent *bev, void *ctx)
|
||||
bufferevent_enable(partner, EV_READ);
|
||||
}
|
||||
|
||||
static void
|
||||
close_on_finished_writecb(struct bufferevent *bev, void *ctx)
|
||||
static void close_on_finished_writecb(struct bufferevent *bev, void *ctx)
|
||||
{
|
||||
struct evbuffer *b = bufferevent_get_output(bev);
|
||||
|
||||
@@ -113,8 +111,7 @@ close_on_finished_writecb(struct bufferevent *bev, void *ctx)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
xfrp_event_cb(struct bufferevent *bev, short what, void *ctx)
|
||||
static void xfrp_event_cb(struct bufferevent *bev, short what, void *ctx)
|
||||
{
|
||||
struct proxy *p = (struct proxy *)ctx;
|
||||
struct bufferevent *partner = p?p->bev:NULL;
|
||||
@@ -145,6 +142,38 @@ xfrp_event_cb(struct bufferevent *bev, short what, void *ctx)
|
||||
}
|
||||
}
|
||||
|
||||
// return: 0: init succeed; 1: init failed
|
||||
// static int init_ftp_data_port(struct proxy_service *ps)
|
||||
// {
|
||||
// struct mycurl_string ret_buf;
|
||||
// if ( ! mycurl_string_init(&ret_buf)) {
|
||||
// debug(LOG_ERR, "error: ftp data port buffer init failed!");
|
||||
// return 1;
|
||||
// }
|
||||
|
||||
// char url[1024] = {0};
|
||||
// struct common_conf *c_conf = get_common_config();
|
||||
|
||||
|
||||
// int state_code = 0;
|
||||
// double down_size = 0;
|
||||
// int ret = net_visit(url,
|
||||
// &ret_buf,
|
||||
// HTTP_GET,
|
||||
// NULL,
|
||||
// 60l,
|
||||
// &state_code,
|
||||
// &down_size);
|
||||
|
||||
// if (ret) {
|
||||
// debug(LOG_ERR, "error: ftp remote data port init failed by HTTP GET");
|
||||
// mycurl_string_free(&ret_buf);
|
||||
// return 1;
|
||||
// }
|
||||
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
int is_ftp_proxy(const struct proxy_service *ps)
|
||||
{
|
||||
if (! ps || ! ps->proxy_type)
|
||||
|
||||
1
client.h
1
client.h
@@ -63,6 +63,7 @@ struct proxy_client {
|
||||
struct proxy_service {
|
||||
char *proxy_name;
|
||||
char *proxy_type;
|
||||
char *ftp_cfg_proxy_name;
|
||||
int use_encryption;
|
||||
int use_compression;
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "commandline.h"
|
||||
#include "debug.h"
|
||||
#include "version.h"
|
||||
#include "utils.h"
|
||||
|
||||
typedef void signal_func (int);
|
||||
|
||||
@@ -122,6 +123,7 @@ usage(const char *appname)
|
||||
fprintf(stdout, " -d <level> Debug level\n");
|
||||
fprintf(stdout, " -h Print usage\n");
|
||||
fprintf(stdout, " -v Print version information\n");
|
||||
fprintf(stdout, " -r Print run id of client\n");
|
||||
fprintf(stdout, "\n");
|
||||
}
|
||||
|
||||
@@ -134,7 +136,7 @@ parse_commandline(int argc, char **argv)
|
||||
int c;
|
||||
int flag = 0;
|
||||
|
||||
while (-1 != (c = getopt(argc, argv, "c:hfd:sw:vx:i:a:"))) {
|
||||
while (-1 != (c = getopt(argc, argv, "c:hfd:sw:vrx:i:a:"))) {
|
||||
|
||||
|
||||
switch (c) {
|
||||
@@ -168,7 +170,25 @@ parse_commandline(int argc, char **argv)
|
||||
fprintf(stdout, "version: " VERSION "\n");
|
||||
exit(1);
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
{
|
||||
char ifname[16] = {0};
|
||||
if(get_net_ifname(ifname, 16)){
|
||||
debug(LOG_ERR, "error: get device sign ifname failed!");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
char if_mac[64] = {0};
|
||||
if(get_net_mac(ifname, if_mac, sizeof(if_mac))) {
|
||||
debug(LOG_ERR, "error: Hard ware MAC address of [%s] get failed!", ifname);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
fprintf(stdout, "run ID:%s\n", if_mac);
|
||||
exit(1);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
|
||||
28
config.c
28
config.c
@@ -145,13 +145,6 @@ static void dump_proxy_service(const int index, struct proxy_service *ps)
|
||||
ps->proxy_type = strdup("tcp");
|
||||
assert(ps->proxy_type);
|
||||
} else if (strcmp(ps->proxy_type, "ftp") == 0) {
|
||||
if (ps->remote_data_port <= 0) {
|
||||
debug(LOG_ERR,
|
||||
"Proxy [%s] error: remote_data_port must be exist when type is ftp",
|
||||
ps->proxy_name);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
new_ftp_data_proxy_service(ps);
|
||||
}
|
||||
|
||||
@@ -183,6 +176,7 @@ static struct proxy_service *new_proxy_service(const char *name)
|
||||
assert(c_conf);
|
||||
|
||||
ps->proxy_name = strdup(name);
|
||||
ps->ftp_cfg_proxy_name = NULL;
|
||||
assert(ps->proxy_name);
|
||||
|
||||
ps->proxy_type = NULL;
|
||||
@@ -217,6 +211,9 @@ static void new_ftp_data_proxy_service(struct proxy_service *ftp_ps)
|
||||
"cannot create ftp data proxy service, it should not happenned!");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
ps->ftp_cfg_proxy_name = strdup(ftp_ps->proxy_name);
|
||||
assert(ps->ftp_cfg_proxy_name);
|
||||
|
||||
ps->proxy_type = strdup("tcp");
|
||||
ps->remote_port = ftp_ps->remote_data_port;
|
||||
@@ -311,8 +308,15 @@ static int common_handler(void *user, const char *section, const char *name, con
|
||||
#define MATCH(s, n) strcmp(section, s) == 0 && strcmp(name, n) == 0
|
||||
if (MATCH("common", "server_addr")) {
|
||||
SAFE_FREE(config->server_addr);
|
||||
config->server_addr = strdup(value);
|
||||
int addr_len = strlen(value) + 1;
|
||||
config->server_addr = (char *)calloc(1, addr_len);
|
||||
assert(config->server_addr);
|
||||
if(dns_unified(value, config->server_addr, addr_len)) {
|
||||
debug(LOG_ERR, "error: server_addr [%s] is invalid!", value);
|
||||
exit(0);
|
||||
}
|
||||
if (is_valid_ip_address(value))
|
||||
set_common_server_ip(value);
|
||||
} else if (MATCH("common", "server_port")) {
|
||||
config->server_port = atoi(value);
|
||||
} else if (MATCH("common", "http_proxy")) {
|
||||
@@ -375,13 +379,14 @@ static void init_common_conf(struct common_conf *config)
|
||||
config->tcp_mux = 0;
|
||||
config->user = NULL;
|
||||
config->server_ip = NULL;
|
||||
config->is_router = 0;
|
||||
}
|
||||
|
||||
// it should be free after using
|
||||
// because of assert it will never return NULL
|
||||
char *get_ftp_data_proxy_name(const char *ftp_proxy_name)
|
||||
{
|
||||
char *ftp_tail_data_name = FTP_DATA_PROXY_SUFFIX;
|
||||
char *ftp_tail_data_name = FTP_RMT_CTL_PROXY_SUFFIX;
|
||||
char *ftp_data_proxy_name = (char *)calloc(1,
|
||||
strlen(ftp_proxy_name)+strlen(ftp_tail_data_name)+1);
|
||||
assert(ftp_data_proxy_name);
|
||||
@@ -425,3 +430,8 @@ void load_config(const char *confile)
|
||||
|
||||
dump_all_ps();
|
||||
}
|
||||
|
||||
int is_running_in_router()
|
||||
{
|
||||
return c_conf->is_router;
|
||||
}
|
||||
|
||||
18
config.h
18
config.h
@@ -29,7 +29,7 @@
|
||||
#include "client.h"
|
||||
#include "common.h"
|
||||
|
||||
#define FTP_DATA_PROXY_SUFFIX "_ftp_data_proxy"
|
||||
#define FTP_RMT_CTL_PROXY_SUFFIX "_ftp_remote_ctl_proxy"
|
||||
|
||||
struct base_conf{
|
||||
char *name;
|
||||
@@ -45,20 +45,23 @@ struct base_conf{
|
||||
|
||||
// common config
|
||||
struct common_conf {
|
||||
char *server_addr; /* default 0.0.0.0 */
|
||||
char *server_addr; /* default 0.0.0.0 */
|
||||
char *server_ip;
|
||||
int server_port; /* default 7000 */
|
||||
int server_port; /* default 7000 */
|
||||
char *http_proxy;
|
||||
char *log_file; /* default consol */
|
||||
char *log_way; /* default console */
|
||||
char *log_level; /* default info */
|
||||
char *log_file; /* default consol */
|
||||
char *log_way; /* default console */
|
||||
char *log_level; /* default info */
|
||||
int log_max_days; /* default 3 */
|
||||
char *privilege_token;
|
||||
char *auth_token;
|
||||
int heartbeat_interval; /* default 10 */
|
||||
int heartbeat_timeout; /* default 30 */
|
||||
int tcp_mux; /* default 0 */
|
||||
int tcp_mux; /* default 0 */
|
||||
char *user;
|
||||
|
||||
/* private fields */
|
||||
int is_router; // to sign router (Openwrt/LEDE) or not
|
||||
};
|
||||
|
||||
struct common_conf *get_common_config();
|
||||
@@ -73,5 +76,6 @@ struct proxy_client *get_all_pc();
|
||||
void load_config(const char *confile);
|
||||
char *get_ftp_data_proxy_name(const char *ftp_proxy_name);
|
||||
void set_common_server_ip(const char *ip);
|
||||
int is_running_in_router();
|
||||
|
||||
#endif //_CONFIG_H_
|
||||
|
||||
65
control.c
65
control.c
@@ -122,7 +122,7 @@ static void new_client_connect()
|
||||
struct proxy_client *client = new_proxy_client();
|
||||
struct common_conf *c_conf = get_common_config();
|
||||
assert(c_conf);
|
||||
client->base = main_ctl->connect_base;;
|
||||
client->base = main_ctl->connect_base;
|
||||
struct bufferevent *bev = connect_server(client->base, c_conf->server_addr, c_conf->server_port);
|
||||
if (!bev) {
|
||||
debug(LOG_DEBUG, "Connect server [%s:%d] failed", c_conf->server_addr, c_conf->server_port);
|
||||
@@ -354,6 +354,50 @@ static void hb_sender_cb(evutil_socket_t fd, short event, void *arg)
|
||||
set_ticker_ping_timer(main_ctl->ticker_ping);
|
||||
}
|
||||
|
||||
// return: 0: raw succeed 1: raw failed
|
||||
static int proxy_service_resp_raw(struct new_proxy_response *npr)
|
||||
{
|
||||
if (npr->error && strlen(npr->error) > 2) {
|
||||
debug(LOG_ERR, "error: new proxy response error_field:%s", npr->error);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((! npr->proxy_name) || (strlen(npr->proxy_name) <= 0)) {
|
||||
debug(LOG_ERR, "error: new proxy response proxy name unmarshal failed!");
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct proxy_service *ps = NULL;
|
||||
ps = get_proxy_service(npr->proxy_name);
|
||||
if (! ps) {
|
||||
debug(LOG_ERR, "error: proxy_name responsed by TypeNewProxyResp not found!");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (! ps->proxy_type) {
|
||||
debug(LOG_ERR, "error: proxy_type is NULL, it should be never happend!");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ps->ftp_cfg_proxy_name) {
|
||||
struct proxy_service *main_ps = get_proxy_service(ps->ftp_cfg_proxy_name);
|
||||
if (main_ps) {
|
||||
debug(LOG_DEBUG, "find main ftp proxy service name [%s]", main_ps->proxy_name);
|
||||
} else {
|
||||
debug(LOG_ERR, "error: cannot find main ftp proxy service!");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (npr->remote_port <= 0) {
|
||||
debug(LOG_ERR, "error: ftp remote_data_port [%d] that request from server is invalid!", npr->remote_port);
|
||||
return 1;
|
||||
}
|
||||
main_ps->remote_data_port = npr->remote_port;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
raw_message(struct message *msg, struct bufferevent *bev, struct proxy_client *client)
|
||||
{
|
||||
@@ -406,7 +450,24 @@ raw_message(struct message *msg, struct bufferevent *bev, struct proxy_client *c
|
||||
break;
|
||||
|
||||
case TypeNewProxyResp:
|
||||
break;
|
||||
{
|
||||
if (msg->data_p == NULL) {
|
||||
debug(LOG_ERR,
|
||||
"recved TypeNewProxyResp but no data, it should be never happend!");
|
||||
break;
|
||||
}
|
||||
|
||||
struct new_proxy_response *npr = new_proxy_resp_unmarshal(msg->data_p);
|
||||
if (npr == NULL) {
|
||||
debug(LOG_ERR, "new proxy response buffer unmarshal faild!");
|
||||
return;
|
||||
}
|
||||
|
||||
proxy_service_resp_raw(npr);
|
||||
|
||||
SAFE_FREE(npr);
|
||||
break;
|
||||
}
|
||||
|
||||
case TypeStartWorkConn:
|
||||
sr = start_work_conn_resp_unmarshal(msg->data_p);
|
||||
|
||||
5
login.c
5
login.c
@@ -73,6 +73,11 @@ void init_login()
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (strcmp(ifname, "br-lan") == 0) {
|
||||
c_conf->is_router = 1;
|
||||
debug(LOG_DEBUG, "working in router");
|
||||
}
|
||||
|
||||
char if_mac[64] = {0};
|
||||
if(get_net_mac(ifname, if_mac, sizeof(if_mac))) {
|
||||
debug(LOG_ERR, "error: Hard ware MAC address of [%s] get failed!", ifname);
|
||||
|
||||
55
msg.c
55
msg.c
@@ -42,6 +42,7 @@
|
||||
#include "common.h"
|
||||
#include "login.h"
|
||||
#include "client.h"
|
||||
#include "utils.h"
|
||||
|
||||
#define JSON_MARSHAL_TYPE(jobj,key,jtype,item) \
|
||||
json_object_object_add(jobj, key, json_object_new_##jtype((item)));
|
||||
@@ -80,7 +81,14 @@ static void fill_custom_domains(struct json_object *j_ctl_req, const char *custo
|
||||
char *tok = tmp, *end = tmp;
|
||||
while (tok != NULL) {
|
||||
strsep(&end, ",");
|
||||
json_object_array_add(jarray_cdomains, json_object_new_string(tok));
|
||||
|
||||
int dname_len = strlen(tok) + 1;
|
||||
char *dname_buf = (char *)calloc(1, dname_len);
|
||||
assert(dname_buf);
|
||||
dns_unified(tok, dname_buf, dname_len);
|
||||
json_object_array_add(jarray_cdomains, json_object_new_string(dname_buf));
|
||||
|
||||
free(dname_buf);
|
||||
tok = end;
|
||||
}
|
||||
SAFE_FREE(tmp);
|
||||
@@ -172,7 +180,6 @@ int new_proxy_service_marshal(const struct proxy_service *np_req, char **msg)
|
||||
JSON_MARSHAL_TYPE(j_np_req, "proxy_type", string, np_req->proxy_type);
|
||||
JSON_MARSHAL_TYPE(j_np_req, "use_encryption", boolean, np_req->use_encryption);
|
||||
JSON_MARSHAL_TYPE(j_np_req, "use_compression", boolean, np_req->use_compression);
|
||||
JSON_MARSHAL_TYPE(j_np_req, "remote_port", int, np_req->remote_port);
|
||||
|
||||
if (is_ftp_proxy(np_req)) {
|
||||
JSON_MARSHAL_TYPE(j_np_req, "remote_data_port", int, np_req->remote_data_port);
|
||||
@@ -180,8 +187,14 @@ int new_proxy_service_marshal(const struct proxy_service *np_req, char **msg)
|
||||
|
||||
if (np_req->custom_domains) {
|
||||
fill_custom_domains(j_np_req, np_req->custom_domains);
|
||||
json_object_object_add(j_np_req, "remote_port", NULL);
|
||||
} else {
|
||||
json_object_object_add(j_np_req, "custom_domains", NULL);
|
||||
if (np_req->remote_port != -1) {
|
||||
JSON_MARSHAL_TYPE(j_np_req, "remote_port", int, np_req->remote_port);
|
||||
} else {
|
||||
json_object_object_add(j_np_req, "remote_port", NULL);
|
||||
}
|
||||
}
|
||||
|
||||
JSON_MARSHAL_TYPE(j_np_req, "subdomain", string, SAFE_JSON_STRING(np_req->subdomain));
|
||||
@@ -229,6 +242,44 @@ int new_work_conn_marshal(const struct work_conn *work_c, char **msg)
|
||||
return nret;
|
||||
}
|
||||
|
||||
// result returned of this func need be free
|
||||
struct new_proxy_response *new_proxy_resp_unmarshal(const char *jres)
|
||||
{
|
||||
struct json_object *j_np_res = json_tokener_parse(jres);
|
||||
if (is_error(j_np_res))
|
||||
return NULL;
|
||||
|
||||
struct new_proxy_response *npr = calloc(1, sizeof(struct new_proxy_response));
|
||||
assert(npr);
|
||||
|
||||
struct json_object *npr_run_id = NULL;
|
||||
if (! json_object_object_get_ex(j_np_res, "run_id", &npr_run_id))
|
||||
goto END_ERROR;
|
||||
npr->run_id = strdup(json_object_get_string(npr_run_id));
|
||||
assert(npr->run_id);
|
||||
|
||||
struct json_object *npr_proxy_remote_port = NULL;
|
||||
if (! json_object_object_get_ex(j_np_res, "remote_port", &npr_proxy_remote_port))
|
||||
goto END_ERROR;
|
||||
npr->remote_port = json_object_get_int(npr_proxy_remote_port);
|
||||
|
||||
struct json_object *npr_proxy_name = NULL;
|
||||
if (! json_object_object_get_ex(j_np_res, "proxy_name", &npr_proxy_name))
|
||||
goto END_ERROR;
|
||||
npr->proxy_name = strdup(json_object_get_string(npr_proxy_name));
|
||||
assert(npr->proxy_name);
|
||||
|
||||
struct json_object *npr_error = NULL;
|
||||
if(! json_object_object_get_ex(j_np_res, "error", &npr_error))
|
||||
goto END_ERROR;
|
||||
npr->error = strdup(json_object_get_string(npr_error));
|
||||
assert(npr->error);
|
||||
|
||||
END_ERROR:
|
||||
json_object_put(j_np_res);
|
||||
return npr;
|
||||
}
|
||||
|
||||
// login_resp_unmarshal NEED FREE
|
||||
struct login_resp *login_resp_unmarshal(const char *jres)
|
||||
{
|
||||
|
||||
8
msg.h
8
msg.h
@@ -67,6 +67,13 @@ struct control_response {
|
||||
char *msg;
|
||||
};
|
||||
|
||||
struct new_proxy_response {
|
||||
char *run_id;
|
||||
char *proxy_name;
|
||||
char *error;
|
||||
int remote_port;
|
||||
};
|
||||
|
||||
struct work_conn {
|
||||
char *run_id;
|
||||
};
|
||||
@@ -91,6 +98,7 @@ size_t pack(struct message *req_msg, unsigned char **ret_buf);
|
||||
struct message *unpack(unsigned char *recv_msg, const ushort len);
|
||||
|
||||
// tranlate control request to json string
|
||||
struct new_proxy_response *new_proxy_resp_unmarshal(const char *jres);
|
||||
struct login_resp *login_resp_unmarshal(const char *jres);
|
||||
struct start_work_conn_resp *start_work_conn_resp_unmarshal(const char *resp_msg);
|
||||
|
||||
|
||||
27
utils.c
27
utils.c
@@ -7,6 +7,7 @@
|
||||
#include <sys/time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <sys/ioctl.h>
|
||||
@@ -180,4 +181,30 @@ int get_net_ifname(char *if_buf, int blen)
|
||||
|
||||
freeifaddrs(ifaddr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
// e.g. wWw.Baidu.com/China will be trans into www.baidu.com/China
|
||||
// return: 0:check and trant succeed, 1:failed or domain name is invalid
|
||||
int dns_unified(const char *dname, char *udname_buf, int udname_buf_len)
|
||||
{
|
||||
if (! dname || ! udname_buf || udname_buf_len < strlen(dname)+1)
|
||||
return 1;
|
||||
|
||||
int has_dot = 0;
|
||||
int dlen = strlen(dname);
|
||||
int i = 0;
|
||||
for(i=0; i<dlen; i++) {
|
||||
if(dname[i] == '/')
|
||||
break;
|
||||
|
||||
if (dname[i] == '.' && i != dlen-1)
|
||||
has_dot = 1;
|
||||
|
||||
udname_buf[i] = tolower(dname[i]);
|
||||
}
|
||||
|
||||
if (! has_dot) //domain name should have 1 dot leastly
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
6
utils.h
6
utils.h
@@ -1,6 +1,11 @@
|
||||
#ifndef _UTILS_H_
|
||||
#define _UTILS_H_
|
||||
|
||||
struct mycurl_string {
|
||||
char *ptr;
|
||||
size_t len;
|
||||
};
|
||||
|
||||
void s_sleep(unsigned int s, unsigned int u);
|
||||
|
||||
// is_valid_ip_address:
|
||||
@@ -9,5 +14,6 @@ int is_valid_ip_address(const char *ip_address);
|
||||
int show_net_ifname();
|
||||
int get_net_ifname(char *if_buf, int blen);
|
||||
int get_net_mac(char *net_if_name, char *mac, int mac_len);
|
||||
int dns_unified(const char *dname, char *udname_buf, int udname_buf_len);
|
||||
|
||||
#endif //_UTILS_H_
|
||||
|
||||
Reference in New Issue
Block a user