mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-25 10:01:30 +00:00
Add documentation for clash_api
This commit is contained in:
parent
6ac1b395cf
commit
45643fbed1
39
docs/configuration/experimental.md
Normal file
39
docs/configuration/experimental.md
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
### Structure
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"experimental": {
|
||||||
|
"clash_api": {
|
||||||
|
"external_controller": "127.0.0.1:9090",
|
||||||
|
"external_ui": "folder",
|
||||||
|
"secret": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Clash API Fields
|
||||||
|
|
||||||
|
!!! error ""
|
||||||
|
|
||||||
|
Clash API is not included by default, see [Installation](/#Installation).
|
||||||
|
|
||||||
|
!!! note ""
|
||||||
|
|
||||||
|
Traffic statistics and connection management will disable TCP splice in linux and reduce performance, use at your own risk.
|
||||||
|
|
||||||
|
#### external_controller
|
||||||
|
|
||||||
|
RESTful web API listening address. Disabled if empty.
|
||||||
|
|
||||||
|
#### external_ui
|
||||||
|
|
||||||
|
A relative path to the configuration directory or an absolute path to a
|
||||||
|
directory in which you put some static web resource. Clash core will then
|
||||||
|
serve it at `http://{{external-controller}}/ui`.
|
||||||
|
|
||||||
|
#### secret
|
||||||
|
|
||||||
|
Secret for the RESTful API (optional)
|
||||||
|
Authenticate by spedifying HTTP header `Authorization: Bearer ${secret}`
|
||||||
|
ALWAYS set a secret if RESTful API is listening on 0.0.0.0
|
|
@ -10,19 +10,21 @@ sing-box uses JSON for configuration files.
|
||||||
"dns": {},
|
"dns": {},
|
||||||
"inbounds": {},
|
"inbounds": {},
|
||||||
"outbounds": {},
|
"outbounds": {},
|
||||||
"route": {}
|
"route": {},
|
||||||
|
"experimental": {}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Fields
|
### Fields
|
||||||
|
|
||||||
| Key | Format |
|
| Key | Format |
|
||||||
|-------------|------------------------|
|
|----------------|--------------------------------|
|
||||||
| `log` | [Log](./log) |
|
| `log` | [Log](./log) |
|
||||||
| `dns` | [DNS](./dns) |
|
| `dns` | [DNS](./dns) |
|
||||||
| `inbounds` | [Inbound](./inbound) |
|
| `inbounds` | [Inbound](./inbound) |
|
||||||
| `outbounds` | [Outbound](./outbound) |
|
| `outbounds` | [Outbound](./outbound) |
|
||||||
| `route` | [Route](./route) |
|
| `route` | [Route](./route) |
|
||||||
|
| `experimental` | [Experimental](./experimental) |
|
||||||
|
|
||||||
### Check
|
### Check
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,20 @@ The universal proxy platform.
|
||||||
sing-box requires Golang 1.18 or a higher version.
|
sing-box requires Golang 1.18 or a higher version.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
go install github.com/sagernet/sing-box/cmd/sing-box@latest
|
go install -v github.com/sagernet/sing-box/cmd/sing-box@latest
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Install with options:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
go install -v -tags "with_clash_api,no_gvisor" github.com/sagernet/sing-box/cmd/sing-box@latest
|
||||||
|
```
|
||||||
|
|
||||||
|
| Build Tag | Description |
|
||||||
|
|------------------|-----------------------------------------------------------------------------------------|
|
||||||
|
| `with_clash_api` | Build with clash api support, see [Experimental](./configuration/experimental). |
|
||||||
|
| `no_gvisor` | Build without gVisor, which required by the [Tun](./configuration/inbound/tun) inbound. |
|
||||||
|
|
||||||
The binary is built under $GOPATH/bin
|
The binary is built under $GOPATH/bin
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|
|
@ -58,7 +58,15 @@ func NewServer(router adapter.Router, logFactory log.ObservableFactory, options
|
||||||
r.Mount("/profile", profileRouter())
|
r.Mount("/profile", profileRouter())
|
||||||
r.Mount("/cache", cacheRouter())
|
r.Mount("/cache", cacheRouter())
|
||||||
})
|
})
|
||||||
|
if options.ExternalUI != "" {
|
||||||
|
chiRouter.Group(func(r chi.Router) {
|
||||||
|
fs := http.StripPrefix("/ui", http.FileServer(http.Dir(options.ExternalUI)))
|
||||||
|
r.Get("/ui", http.RedirectHandler("/ui/", http.StatusTemporaryRedirect).ServeHTTP)
|
||||||
|
r.Get("/ui/*", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
fs.ServeHTTP(w, r)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
return &Server{
|
return &Server{
|
||||||
logFactory.NewLogger("clash-api"),
|
logFactory.NewLogger("clash-api"),
|
||||||
&http.Server{
|
&http.Server{
|
||||||
|
|
|
@ -62,6 +62,7 @@ nav:
|
||||||
- Geosite: configuration/route/geosite.md
|
- Geosite: configuration/route/geosite.md
|
||||||
- Route Rule: configuration/route/rule.md
|
- Route Rule: configuration/route/rule.md
|
||||||
- Protocol Sniff: configuration/route/sniff.md
|
- Protocol Sniff: configuration/route/sniff.md
|
||||||
|
- Experimental: configuration/experimental.md
|
||||||
- Examples:
|
- Examples:
|
||||||
- examples/index.md
|
- examples/index.md
|
||||||
- Shadowsocks Server: examples/ss-server.md
|
- Shadowsocks Server: examples/ss-server.md
|
||||||
|
|
|
@ -6,5 +6,6 @@ type ExperimentalOptions struct {
|
||||||
|
|
||||||
type ClashAPIOptions struct {
|
type ClashAPIOptions struct {
|
||||||
ExternalController string `json:"external_controller,omitempty"`
|
ExternalController string `json:"external_controller,omitempty"`
|
||||||
|
ExternalUI string `json:"external_ui,omitempty"`
|
||||||
Secret string `json:"secret,omitempty"`
|
Secret string `json:"secret,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue