Skip to content

Commit

Permalink
fix: dhcp:// with special notation cannot be parsed
Browse files Browse the repository at this point in the history
  • Loading branch information
xishang0128 committed Jun 23, 2024
1 parent a9ecc62 commit 9f4cd64
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 0 additions & 1 deletion component/process/process_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ func findPackageName(uid uint32) string {
})

if sharedPackage, loaded := packageManager.SharedPackageByID(uid % 100000); loaded {
fmt.Println(loaded)
return sharedPackage
}
if packageName, loaded := packageManager.PackageByID(uid % 100000); loaded {
Expand Down
14 changes: 11 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,16 @@ func parseNameServer(servers []string, respectRules bool, preferH3 bool) ([]dns.
var nameservers []dns.NameServer

for idx, server := range servers {
if strings.HasPrefix(server, "dhcp://") {
nameservers = append(
nameservers,
dns.NameServer{
Net: "dhcp",
Addr: server[len("dhcp://"):],
},
)
continue
}
server = parsePureDNSServer(server)
u, err := url.Parse(server)
if err != nil {
Expand Down Expand Up @@ -1099,9 +1109,6 @@ func parseNameServer(servers []string, respectRules bool, preferH3 bool) ([]dns.
}
}
}
case "dhcp":
addr = u.Host
dnsNetType = "dhcp" // UDP from DHCP
case "quic":
addr, err = hostWithDefaultPort(u.Host, "853")
dnsNetType = "quic" // DNS over QUIC
Expand Down Expand Up @@ -1174,6 +1181,7 @@ func parsePureDNSServer(server string) string {
}
}
}

func parseNameServerPolicy(nsPolicy *orderedmap.OrderedMap[string, any], ruleProviders map[string]providerTypes.RuleProvider, respectRules bool, preferH3 bool) (*orderedmap.OrderedMap[string, []dns.NameServer], error) {
policy := orderedmap.New[string, []dns.NameServer]()
updatedPolicy := orderedmap.New[string, any]()
Expand Down

0 comments on commit 9f4cd64

Please sign in to comment.