|
@@ -138,15 +138,12 @@ type HostInfo struct {
|
|
|
// url 格式:ws2://xor:s^7mv7L!Mrn8Y!vn@127.0.0.1:14541/wsv2?proxy=1
|
|
// url 格式:ws2://xor:s^7mv7L!Mrn8Y!vn@127.0.0.1:14541/wsv2?proxy=1
|
|
|
// 仅支持客户端连接使用
|
|
// 仅支持客户端连接使用
|
|
|
func ParseUrl(url string) (hostInfo *HostInfo, err error) {
|
|
func ParseUrl(url string) (hostInfo *HostInfo, err error) {
|
|
|
- mx := regexp.MustCompile(`^([a-z]+)([0-9]+)://([^/#\?]+)(/[\w\-/]+)?`).FindStringSubmatch(url)
|
|
|
|
|
|
|
+ mx := regexp.MustCompile(`^([a-z]+)([0-9]*)://([^/\?]+)(/[\w\-/]+)?`).FindStringSubmatch(url)
|
|
|
if mx == nil {
|
|
if mx == nil {
|
|
|
return nil, errors.New("invalid url")
|
|
return nil, errors.New("invalid url")
|
|
|
}
|
|
}
|
|
|
protocol := mx[1]
|
|
protocol := mx[1]
|
|
|
- version, err := strconv.Atoi(mx[2])
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- return nil, err
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ version, _ := strconv.Atoi(mx[2])
|
|
|
host := mx[3]
|
|
host := mx[3]
|
|
|
index := strings.LastIndex(host, "@")
|
|
index := strings.LastIndex(host, "@")
|
|
|
hash := ""
|
|
hash := ""
|