Skip to content

Commit

Permalink
doc: document proxy scheme
Browse files Browse the repository at this point in the history
Signed-off-by: hexian000 <hexian000@outlook.com>
  • Loading branch information
hexian000 committed Aug 16, 2023
1 parent eb5a41e commit 15d1e4d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
21 changes: 6 additions & 15 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ Trigger a full GC.
**Synopsis**

```Lua
function ruleset.resolve(domain, source)
return "www.example.org:80", "http://203.0.113.1:8080", ..., "[2001:DB8::1]:1080"
function ruleset.resolve(domain)
return "www.example.org:80", "203.0.113.1:1080", ..., "[2001:DB8::1]:1080"
end
```

Expand All @@ -78,7 +78,6 @@ Process a host name request. Specifically:
**Params**

- `domain`: full qualified domain name and port, like `"www.example.org:80"`
- `source`: the address and port of the client making this request, like `"203.0.113.1:54321"`

**Returns**

Expand All @@ -87,20 +86,14 @@ Process a host name request. Specifically:
- `addr, proxyN, ..., proxy1`: forward the request through proxy chain
- `nil`: reject the request

Proxy protocols can be specified in URI scheme:

- `203.0.113.1:1080`: SOCKS4A is the default
- `socks4a://203.0.113.1:1080`: if making IPv4 request, this protocol is compatible with standard SOCKS4
- `socks5://203.0.113.1:1080`: name resolution is performed remotely
- `http://203.0.113.1:1080`: HTTP CONNECT proxy

### ruleset.route

**Synopsis**

```Lua
function ruleset.route(addr, source)
return "www.example.org:80", "http://203.0.113.1:8080", ..., "[2001:DB8::1]:1080"
function ruleset.route(addr)
return "www.example.org:80", "203.0.113.1:1080", ..., "[2001:DB8::1]:1080"
end
```

Expand All @@ -113,7 +106,6 @@ Process an IPv4 request. Specifically:
**Params**

- `addr`: address and port, like `"203.0.113.1:80"`
- `source`: the address and port of the client making this request, like `"203.0.113.1:54321"`

**Returns**

Expand All @@ -125,8 +117,8 @@ See [ruleset.resolve](#rulesetresolve)
**Synopsis**

```Lua
function ruleset.route6(addr, source)
return "www.example.org:80", "http://203.0.113.1:8080", ..., "[2001:DB8::1]:1080"
function ruleset.route6(addr)
return "www.example.org:80", "203.0.113.1:1080", ..., "[2001:DB8::1]:1080"
end
```

Expand All @@ -139,7 +131,6 @@ Process an IPv6 request. Specifically:
**Params**

- `addr`: address and port, like `"[2001:DB8::1]:80"`
- `source`: the address and port of the client making this request, like `"203.0.113.1:54321"`

**Returns**

Expand Down
4 changes: 3 additions & 1 deletion src/dialer.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ bool dialreq_proxy(
uri.host = uri.defacto;
} else if (strcmp(uri.scheme, "http") == 0) {
protocol = PROTO_HTTP;
} else if (strcmp(uri.scheme, "socks4a") == 0) {
} else if (
strcmp(uri.scheme, "socks4") == 0 ||
strcmp(uri.scheme, "socks4a") == 0) {
protocol = PROTO_SOCKS4A;
} else if (strcmp(uri.scheme, "socks5") == 0) {
protocol = PROTO_SOCKS5;
Expand Down
1 change: 0 additions & 1 deletion src/http_proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include "conf.h"
#include "ruleset.h"

#include "utils/check.h"
#include <ev.h>

static void xfer_state_cb(struct ev_loop *loop, void *data)
Expand Down

0 comments on commit 15d1e4d

Please sign in to comment.