url添加mux配置;修订api server

This commit is contained in:
e1732a364fed
2000-01-01 00:00:00 +00:00
parent e6800cc605
commit c5972830ce
4 changed files with 42 additions and 20 deletions

View File

@@ -8,6 +8,7 @@ import (
"log"
"net/http"
"strconv"
"strings"
"time"
"github.com/e1732a364fed/v2ray_simple/configAdapter"
@@ -63,10 +64,25 @@ func tryRunApiServer() {
}
const eIllegalParameter = "illegal parameter"
// 阻塞
func runApiServer(adminUUID string) {
utils.Info("Start Api Server at " + apiServerAddr)
var addrStr = apiServerAddr
if apiServerPlainHttp {
if !strings.HasPrefix(addrStr, "http://") {
addrStr = "http://" + addrStr
}
} else {
if !strings.HasPrefix(addrStr, "https://") {
addrStr = "https://" + addrStr
}
}
utils.Info("Start Api Server at " + addrStr)
ser := newApiServer("admin", adminUUID)
@@ -85,8 +101,6 @@ func runApiServer(adminUUID string) {
ser.addServerHandle(mux, "hotDelete", func(w http.ResponseWriter, r *http.Request) {
q := r.URL.Query()
const eInfo = "illegal parameter"
listenIndexStr := q.Get("listen")
dialIndexStr := q.Get("dial")
if listenIndexStr != "" {
@@ -96,9 +110,9 @@ func runApiServer(adminUUID string) {
listenIndex, err := strconv.Atoi(listenIndexStr)
if err != nil {
failBadRequest(err, eInfo, w)
failBadRequest(err, eIllegalParameter, w)
w.Write([]byte(eInfo))
w.Write([]byte(eIllegalParameter))
return
}
hotDeleteServer(listenIndex)
@@ -111,9 +125,9 @@ func runApiServer(adminUUID string) {
dialIndex, err := strconv.Atoi(dialIndexStr)
if err != nil {
failBadRequest(err, eInfo, w)
failBadRequest(err, eIllegalParameter, w)
w.Write([]byte(eInfo))
w.Write([]byte(eIllegalParameter))
return
}
hotDeleteClient(dialIndex)
@@ -179,8 +193,6 @@ func runApiServer(adminUUID string) {
ser.addServerHandle(mux, "getDetailUrl", func(w http.ResponseWriter, r *http.Request) {
q := r.URL.Query()
const eInfo = "illegal parameter"
indexStr := q.Get("index")
isDial := utils.QueryPositive(q, "isDial")
if indexStr != "" {
@@ -190,9 +202,9 @@ func runApiServer(adminUUID string) {
ind, err := strconv.Atoi(indexStr)
if err != nil || ind < 0 || (isDial && ind >= len(allClients)) || (!isDial && ind >= len(allServers)) {
failBadRequest(err, eInfo, w)
failBadRequest(err, eIllegalParameter, w)
w.Write([]byte(eInfo))
w.Write([]byte(eIllegalParameter))
return
}
if isDial {

View File

@@ -69,6 +69,9 @@ func ToVS(cc *proxy.CommonConf, dc *proxy.DialConf, lc *proxy.ListenConf) string
if dc.SendThrough != "" {
q.Add("sendThrough", dc.SendThrough)
}
if dc.Mux {
q.Add("mux", "true")
}
}
if cc.TLS {

View File

@@ -23,19 +23,20 @@ authority = [userinfo "@"] host [":" port]
## 举例
```
socks5://127.0.0.1:1080#my_socks5
socks5://myusername:mypassword@127.0.0.1:1080#my_socks5_safe
dokodemo://127.0.0.1:1081?target.ip=1.1.1.1&target.port=80#my_doko
shadowsocks://aes-128-gcm:mypasswordxxxxx@127.0.0.1:8000#my_ss
vmess://a684455c-b14f-11ea-bf0d-42010aaa0003@127.0.0.1:4433/mypath?http=true&header.host=myhost.com
vlesss://a684455c-b14f-11ea-bf0d-42010aaa0003@127.0.0.1:4433?insecure=true&v=0&utls=true#my_vless1
vlesss://a684455c-b14f-11ea-bf0d-42010aaa0003@127.0.0.1:4433?adv=quic&v=0&extra.maxStreamsInOneConn=6&extra.congestion_control=hy&extra.mbps=1024#my_vless_quic
vmess://a684455c-b14f-11ea-bf0d-42010aaa0003@127.0.0.1:4433/mypath?http=true&header.host=myhost.com
dokodemo://?target.ip=1.1.1.1&target.port=80#my_doko
shadowsocks://aes-128-gcm:mypasswordxxxxx@127.0.0.1:8000#my_ss
socks5://myusername:mypassword@127.0.0.1:1080#my_socks5_safe
socks5://127.0.0.1:1080#my_socks5
```
@@ -92,6 +93,8 @@ adv=ws 设置使用的高级层,如不给出则没有高级层,如给出,
sendThrough=0.0.0.0:0 dial一般为direct设置发送时所使用的端口
mux=true 设置内层多路复用使用smux
### http 头相关
http=true 设置是否使用http头

View File

@@ -246,6 +246,10 @@ func URLToDialConf(u *url.URL, conf *DialConf) error {
}
if utils.QueryPositive(q, "mux") {
conf.Mux = true
}
return e
}