Files
v2ray_simple/proxy/config_urlConf.go
e1732a364fed b3ebc52037 修订代码
2022-12-24 16:41:19 +08:00

40 lines
691 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package proxy
import (
"log"
"net/url"
)
type UrlConf struct {
ListenUrl string `json:"listen"`
DialUrl string `json:"dial"`
}
// listenURL 不可为空。dialURL如果为空会自动被设为 DirectURL
func LoadUrlConf(listenURL, dialURL string) (urlConf UrlConf, err error) {
if dialURL == "" {
dialURL = DirectURL
}
_, err = url.Parse(listenURL)
if err != nil {
log.Printf("listenURL given but invalid %s %s\n", listenURL, err.Error())
return
}
urlConf = UrlConf{
ListenUrl: listenURL,
}
_, err = url.Parse(dialURL)
if err != nil {
log.Printf("dialURL given but invalid %s %s\n", dialURL, err.Error())
return
}
urlConf.DialUrl = dialURL
return
}