Skip to content

Commit

Permalink
fix sth
Browse files Browse the repository at this point in the history
  • Loading branch information
xjasonlyu committed Jul 23, 2024
1 parent cd8c2f5 commit ef896bf
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func netstack(k *Key) (err error) {
}
}()

if _defaultProxy, err = parseProxy(k.Proxy); err != nil {
if _defaultProxy, err = proxy.ParseFromURL(k.Proxy); err != nil {
return
}
proxy.DefaultProxy = _defaultProxy
Expand Down
5 changes: 0 additions & 5 deletions engine/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/xjasonlyu/tun2socks/v2/core/device"
"github.com/xjasonlyu/tun2socks/v2/core/device/fdbased"
"github.com/xjasonlyu/tun2socks/v2/core/device/tun"
"github.com/xjasonlyu/tun2socks/v2/proxy"
)

func parseRestAPI(s string) (*url.URL, error) {
Expand Down Expand Up @@ -65,10 +64,6 @@ func parseFD(u *url.URL, mtu uint32) (device.Device, error) {
return fdbased.Open(u.Host, mtu, 0)
}

func parseProxy(s string) (proxy.Proxy, error) {
return proxy.ParseFromURL(s)
}

func parseMulticastGroups(s string) (multicastGroups []net.IP, _ error) {
ipStrings := strings.Split(s, ",")
for _, ipString := range ipStrings {
Expand Down
2 changes: 1 addition & 1 deletion proxy/direct/direct.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const protocol = "direct"

type Direct struct{ *base.Base }

func New() *Direct { return &Direct{base.New(protocol, "")} }
func New() *Direct { return &Direct{base.New("", protocol)} }

func Parse(*url.URL) (proxy.Proxy, error) { return New(), nil }

Expand Down
2 changes: 1 addition & 1 deletion proxy/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type HTTP struct {

func New(addr, user, pass string) (*HTTP, error) {
return &HTTP{
Base: base.New(protocol, addr),
Base: base.New(addr, protocol),
user: user,
pass: pass,
}, nil
Expand Down
3 changes: 2 additions & 1 deletion proxy/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package proxy

import (
"errors"
"fmt"
"net/url"
"sync"

Expand Down Expand Up @@ -56,7 +57,7 @@ func Parse(proxyURL *url.URL) (Proxy, error) {
}
p := pick(proxyURL.Scheme)
if p.parse == nil {
return nil, ErrProtocol
return nil, fmt.Errorf("%w: %s", ErrProtocol, proxyURL.Scheme)
}
return p.parse(proxyURL)
}
Expand Down
2 changes: 1 addition & 1 deletion proxy/relay/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type Relay struct {

func New(addr, user, pass string, noDelay bool) (*Relay, error) {
return &Relay{
Base: base.New(protocol, addr),
Base: base.New(addr, protocol),
user: user,
pass: pass,
noDelay: noDelay,
Expand Down
2 changes: 1 addition & 1 deletion proxy/shadowsocks/shadowsocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func New(addr, method, password, obfsMode, obfsHost string) (*Shadowsocks, error
}

return &Shadowsocks{
Base: base.New(protocol, addr),
Base: base.New(addr, protocol),
cipher: cipher,
obfsMode: obfsMode,
obfsHost: obfsHost,
Expand Down
2 changes: 1 addition & 1 deletion proxy/socks5/socks5.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type Socks5 struct {

func New(addr, user, pass string) (*Socks5, error) {
return &Socks5{
Base: base.New(protocol, addr),
Base: base.New(addr, protocol),
user: user,
pass: pass,
unix: len(addr) > 0 && addr[0] == '/',
Expand Down

0 comments on commit ef896bf

Please sign in to comment.