Skip to content

Commit

Permalink
Add allow connection from lan
Browse files Browse the repository at this point in the history
  • Loading branch information
0xConsumer committed Jan 1, 2024
1 parent 2fa07be commit 6f01b45
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions shared/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type ConfigOptions struct {
EnableTun bool `json:"enable-tun"`
SetSystemProxy bool `json:"set-system-proxy"`
BypassLAN bool `json:"bypass-lan"`
AllowConnectionFromLAN bool `json:"allow-connection-from-lan"`
EnableFakeDNS bool `json:"enable-fake-dns"`
EnableDNSRouting bool `json:"enable-dns-routing"`
IndependentDNSCache bool `json:"independent-dns-cache"`
Expand Down Expand Up @@ -78,6 +79,13 @@ func BuildConfig(configOpt ConfigOptions, input option.Options) option.Options {
directDNSDomains := []string{}
dnsRules := []option.DefaultDNSRule{}

var bind string
if configOpt.AllowConnectionFromLAN {
bind = "0.0.0.0"
} else {
bind = "127.0.0.1"
}

if configOpt.EnableClashApi {
options.Experimental = &option.ExperimentalOptions{
ClashAPI: &option.ClashAPIOptions{
Expand Down Expand Up @@ -177,7 +185,7 @@ func BuildConfig(configOpt ConfigOptions, input option.Options) option.Options {
Tag: "mixed-in",
MixedOptions: option.HTTPMixedInboundOptions{
ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.MustParseAddr("127.0.0.1")),
Listen: option.NewListenAddress(netip.MustParseAddr(bind)),
ListenPort: configOpt.MixedPort,
InboundOptions: option.InboundOptions{
SniffEnabled: true,
Expand All @@ -197,7 +205,7 @@ func BuildConfig(configOpt ConfigOptions, input option.Options) option.Options {
Tag: "dns-in",
DirectOptions: option.DirectInboundOptions{
ListenOptions: option.ListenOptions{
Listen: option.NewListenAddress(netip.MustParseAddr("127.0.0.1")),
Listen: option.NewListenAddress(netip.MustParseAddr(bind)),
ListenPort: configOpt.LocalDnsPort,
},
OverrideAddress: "8.8.8.8",
Expand Down

0 comments on commit 6f01b45

Please sign in to comment.