Skip to content

Commit

Permalink
Merge branch 'fix-conf'
Browse files Browse the repository at this point in the history
  • Loading branch information
hmgle committed May 26, 2024
2 parents 3f645ab + f4e3a7a commit 14f8d40
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
12 changes: 8 additions & 4 deletions conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,12 @@ static const struct graftcp_config_t *graftcp_getconfig(const char *key)
{
int i;

for (i = 0; i < config_size; i++)
if (!strncmp(config[i].name, key, strlen(config[i].name)))
#define MAX(a,b) (((a)>(b))?(a):(b))
for (i = 0; i < config_size; i++) {
if (!strncmp(config[i].name, key, MAX(strlen(config[i].name), strlen(key))))
return &config[i];
}
#undef MAX
return NULL;
}

Expand Down Expand Up @@ -120,8 +123,9 @@ static int right_space(char *buf, size_t len)
{
int i;
for (i = len - 1; i >= 0; i--)
if (buf[i] != ' ' && buf[i] != '\t' && buf[i] != '\0')
return i;
if (buf[i] != ' ' && buf[i] != '\t' && buf[i] != '\0' &&
buf[i] != '\n' && buf[i] != '\r')
return i + 1;
return 0;
}

Expand Down
21 changes: 21 additions & 0 deletions example-graftcp.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## graftcp-local's IP address. Default: localhost
# local_addr = localhost

## Which port is graftcp-local listening? Default: 2233
# local_port = 2233

## Path of fifo to communicate with graftcp-local.
## Default: /tmp/graftcplocal.fifo
# pipepath = /tmp/graftcplocal.fifo

## The IP/CIDR in black-ip-file will connect direct
# blackip_file_path =


## Only redirect the connect that destination IP/CIDR in
## the white-ip-file to SOCKS5
# whiteip_file_path =

## Connecting to local is not changed by default, this
## option will redirect it to SOCKS5
# ignore_local

0 comments on commit 14f8d40

Please sign in to comment.