mirror of
https://github.com/SagerNet/sing-box.git
synced 2025-04-02 03:17:35 +03:00
documentation: Fix missing hosts DNS server
This commit is contained in:
parent
e7ad8d294d
commit
331edbacff
3 changed files with 74 additions and 1 deletions
|
@ -2,12 +2,14 @@ package hosts
|
|||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
|
||||
"github.com/sagernet/sing-box/adapter"
|
||||
C "github.com/sagernet/sing-box/constant"
|
||||
"github.com/sagernet/sing-box/dns"
|
||||
"github.com/sagernet/sing-box/log"
|
||||
"github.com/sagernet/sing-box/option"
|
||||
"github.com/sagernet/sing/service/filemanager"
|
||||
|
||||
mDNS "github.com/miekg/dns"
|
||||
)
|
||||
|
@ -29,7 +31,7 @@ func NewTransport(ctx context.Context, logger log.ContextLogger, tag string, opt
|
|||
files = append(files, NewFile(DefaultPath))
|
||||
} else {
|
||||
for _, path := range options.Path {
|
||||
files = append(files, NewFile(path))
|
||||
files = append(files, NewFile(filemanager.BasePath(ctx, os.ExpandEnv(path))))
|
||||
}
|
||||
}
|
||||
return &Transport{
|
||||
|
|
70
docs/configuration/dns/server/hosts.md
Normal file
70
docs/configuration/dns/server/hosts.md
Normal file
|
@ -0,0 +1,70 @@
|
|||
---
|
||||
icon: material/new-box
|
||||
---
|
||||
|
||||
!!! question "Since sing-box 1.12.0"
|
||||
|
||||
# Hosts
|
||||
|
||||
### Structure
|
||||
|
||||
```json
|
||||
{
|
||||
"dns": {
|
||||
"servers": [
|
||||
{
|
||||
"type": "hosts",
|
||||
"tag": "",
|
||||
|
||||
"path": [],
|
||||
"predefined": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
!!! note ""
|
||||
|
||||
You can ignore the JSON Array [] tag when the content is only one item
|
||||
|
||||
### Fields
|
||||
|
||||
#### path
|
||||
|
||||
List of paths to hosts files.
|
||||
|
||||
`/etc/hosts` is used by default.
|
||||
|
||||
`C:\Windows\System32\Drivers\etc\hosts` is used by default on Windows.
|
||||
|
||||
Example:
|
||||
|
||||
```json
|
||||
{
|
||||
// "path": "/etc/hosts"
|
||||
|
||||
"path": [
|
||||
"/etc/hosts",
|
||||
"$HOME/.hosts"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
#### predefined
|
||||
|
||||
Predefined hosts.
|
||||
|
||||
Example:
|
||||
|
||||
```json
|
||||
{
|
||||
"predefined": {
|
||||
"www.google.com": "127.0.0.1",
|
||||
"localhost": [
|
||||
"127.0.0.1",
|
||||
"::1"
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
|
@ -84,6 +84,7 @@ nav:
|
|||
- configuration/dns/server/index.md
|
||||
- Legacy: configuration/dns/server/legacy.md
|
||||
- Local: configuration/dns/server/local.md
|
||||
- Hosts: configuration/dns/server/hosts.md
|
||||
- TCP: configuration/dns/server/tcp.md
|
||||
- UDP: configuration/dns/server/udp.md
|
||||
- TLS: configuration/dns/server/tls.md
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue