Skip to content

Commit

Permalink
doc: update examples
Browse files Browse the repository at this point in the history
Signed-off-by: He Xian <[email protected]>
  • Loading branch information
hexian000 committed Oct 26, 2024
1 parent 0ca43e5 commit e659f3d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
1 change: 1 addition & 0 deletions agent.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ agent.hosts = table.get(_G, "agent", "hosts")

local API_ENDPOINT = "api.neosocksd.internal:80"
local INTERNAL_DOMAIN = ".internal"
-- <host>.peerN.peer2.peer1.relay.neosocksd.internal
local RELAY_DOMAIN = ".relay.neosocksd.internal"

-- _G.peerdb[peername] = { hosts = { hostname, "host1" } }, timestamp = os.time() }
Expand Down
26 changes: 13 additions & 13 deletions ruleset.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@ local INTERNAL_DOMAIN = ".internal"

-- _G.redirect_name: for requests with name string
_G.redirect_name = {
-- access mDNS sites directly
{ match.domain(".local"), rule.direct() },
-- loopback, rule.redirect(addr, proxy1, proxy2, ...)
{ match.exact("peer0.lan:22"), rule.redirect("host-gateway:22"), "ssh" },
{ match.exact("peer0.lan:80"), rule.redirect("nginx:80"), "web" },
{ match.exact("peer0.lan:443"), rule.redirect("nginx:443"), "web" },
-- internal assignment
{ match.exact(API_ENDPOINT), rule.redirect("127.0.1.1:9080") },
{ match.agent(), rule.agent() },
{ match.exact("peer0.internal:22"), rule.redirect("host-gateway:22"), "ssh" },
{ match.domain(INTERNAL_DOMAIN), rule.reject() },
-- rule.redirect(addr, proxy1, proxy2, ...)
{ match.exact("peer0.lan:22"), rule.redirect("host-gateway:22"), "ssh" },
{ match.exact("peer0.lan:80"), rule.redirect("nginx:80"), "web" },
{ match.exact("peer0.lan:443"), rule.redirect("nginx:443"), "web" },
-- access local sites directly
{ match.domain({ ".lan", ".local" }), rule.direct(), "lan" },
-- ".internal" assignment
{ match.exact(API_ENDPOINT), rule.redirect("127.0.1.1:9080") },
{ match.agent(), rule.agent() }, -- agent relay
{ match.exact("peer0.internal:22"), rule.redirect("host-gateway:22"), "ssh" },
{ match.domain(INTERNAL_DOMAIN), rule.reject(), "unknown" },
-- global condition
{ is_disabled, rule.reject(), "off" },
{ is_disabled, rule.reject(), "off" },
-- dynamically loaded big domains list, rule.proxy(proxy1, proxy2, ...)
{ composite.maybe(_G, "biglist"), rule.proxy("socks4a://proxy.lan:1080"), "biglist" },
{ composite.maybe(_G, "biglist"), rule.proxy("socks4a://proxy.lan:1080"), "biglist" },
-- if in _G.hosts, go to _G.route/_G.route6
-- otherwise, go to _G.route_default
}
Expand Down

0 comments on commit e659f3d

Please sign in to comment.