Skip to content

Commit

Permalink
Update dependency version
Browse files Browse the repository at this point in the history
  • Loading branch information
enfein committed Feb 20, 2025
1 parent a87e63a commit 2991cf1
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 57 deletions.
3 changes: 2 additions & 1 deletion apis/common/dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ import (
"net"
)

// Dial provides methods to establish stream oriented connections.
type Dialer interface {
DialContext(ctx context.Context, network, address string) (net.Conn, error)
}

var _ Dialer = &net.Dialer{}
var _ Dialer = (*net.Dialer)(nil)
4 changes: 2 additions & 2 deletions apis/common/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ type DNSResolver interface {
LookupIP(ctx context.Context, network, host string) ([]net.IP, error)
}

// Standard library Resolver implements the DNSResolver interface.
var _ DNSResolver = &net.Resolver{}
// Standard library net.Resolver implements the DNSResolver interface.
var _ DNSResolver = (*net.Resolver)(nil)

// NilDNSResolver implements the DNSResolver interface but
// it is not able to look up IP addresses.
Expand Down
2 changes: 1 addition & 1 deletion docs/client-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ The format of the simple sharing link is as follows:

A simple sharing link starts with `mierus://`, where `s` stands for `simple`.

The username and password can only use uppercase letters `A-Z`, lowercase letters `a-z`, numbers `0-9`, underscores `_`, and hyphens `-`. Otherwise, a simple sharing link cannot be generated.
Some special characters are not allowed in username or password. In case a character is not allowed, the simple sharing link cannot be generated.

There is only one server address in a simple sharing link. If the client's configuration contains multiple servers, multiple links will be generated.

Expand Down
2 changes: 1 addition & 1 deletion docs/client-install.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ mierus://baozi:[email protected]?mtu=1400&multiplexing=MULTIPLEXING_HIGH&por

简单分享链接以 `mierus://` 开始,其中 `s` 表示 `simple`

用户名和密码只能使用大写字母 `A-Z`,小写字母 `a-z`,数字 `0-9`,下划线 `_` 和横杠 `-`,否则将无法生成简单分享链接
用户名和密码不允许使用某些特殊字符。如果使用了不允许的字符,则无法生成简单分享链接

简单分享链接中只有一个服务器地址。如果客户端的设置含有多台服务器,则会生成多个链接。

Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ go 1.20

require (
github.com/google/btree v1.1.3
golang.org/x/crypto v0.32.0
golang.org/x/sys v0.29.0
golang.org/x/crypto v0.33.0
golang.org/x/sys v0.30.0
google.golang.org/grpc v1.64.1
google.golang.org/protobuf v1.34.2
)

require (
golang.org/x/net v0.26.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/text v0.22.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240610135401-a8a62080eff3 // indirect
)
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
github.com/google/btree v1.1.3 h1:CVpQJjYgC4VbzxeGVHfvZrv1ctoYCAI8vbl07Fcxlyg=
github.com/google/btree v1.1.3/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc=
golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus=
golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M=
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240610135401-a8a62080eff3 h1:9Xyg6I9IWQZhRVfCWjKK+l6kI0jHcPesVlMnT//aHNo=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240610135401-a8a62080eff3/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0=
google.golang.org/grpc v1.64.1 h1:LKtvyfbX3UGVPFcGqJ9ItpVWW6oN/2XqTxfAnwRRXiA=
Expand Down
10 changes: 7 additions & 3 deletions pkg/appctl/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ import (
"google.golang.org/protobuf/proto"
)

const (
safeURLPattern = `^[0-9A-Za-z_!\$&'\(\)\*\+,;=\.\~-]+$`
)

var (
safeURLRegExp = regexp.MustCompile(`^[0-9A-Za-z_!\$&'\(\)\*\+,;=\.\~-]+$`)
safeURLRegExp = regexp.MustCompile(safeURLPattern)
)

// ClientConfigToURL creates a URL to share the client configuration.
Expand Down Expand Up @@ -63,13 +67,13 @@ func ClientProfileToMultiURLs(profile *pb.ClientProfile) (urls []string, err err
return nil, fmt.Errorf("user name in profile %s is empty", profileName)
}
if !isSafeURLString(userName) {
return nil, fmt.Errorf(`user name %q in profile %s can't be safely encoded to URL. Only allow "A-Z", "a-z", "0-9", underscore "_", and hyphen "-"`, userName, profileName)
return nil, fmt.Errorf(`user name %q in profile %s can't be safely encoded to URL. Allowed pattern: %s`, userName, profileName, safeURLPattern)
}
if password == "" {
return nil, fmt.Errorf("password in profile %s is empty", profileName)
}
if !isSafeURLString(password) {
return nil, fmt.Errorf(`password %q in profile %s can't be safely encoded to URL. Only allow "A-Z", "a-z", "0-9", underscore "_", and hyphen "-"`, password, profileName)
return nil, fmt.Errorf(`password %q in profile %s can't be safely encoded to URL. Allowed pattern: %s`, password, profileName, safeURLPattern)
}
if len(servers) == 0 {
return nil, fmt.Errorf("profile %s has no server", profileName)
Expand Down
40 changes: 0 additions & 40 deletions pkg/protocol/mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,53 +329,13 @@ func (m *Mux) DialContext(ctx context.Context) (net.Conn, error) {
}

func (m *Mux) ExportSessionInfoList() *appctlpb.SessionInfoList {
// header := SessionInfo{
// ID: "Session ID",
// Protocol: "Protocol",
// LocalAddr: "Local",
// RemoteAddr: "Remote",
// State: "State",
// RecvQBuf: "Recv Q+Buf",
// SendQBuf: "Send Q+Buf",
// LastRecv: "Last Recv",
// LastSend: "Last Send",
// }
items := make([]*appctlpb.SessionInfo, 0)
m.mu.Lock()
for _, underlay := range m.underlays {
items = append(items, underlay.SessionInfos()...)
}
m.mu.Unlock()
return &appctlpb.SessionInfoList{Items: items}

// var idLen, protocolLen, localAddrLen, remoteAddrLen, stateLen, recvQLen, sendQLen, lastRecvLen, lastSendLen int
// for _, si := range info {
// idLen = mathext.Max(idLen, len(si.ID))
// protocolLen = mathext.Max(protocolLen, len(si.Protocol))
// localAddrLen = mathext.Max(localAddrLen, len(si.LocalAddr))
// remoteAddrLen = mathext.Max(remoteAddrLen, len(si.RemoteAddr))
// stateLen = mathext.Max(stateLen, len(si.State))
// recvQLen = mathext.Max(recvQLen, len(si.RecvQBuf))
// sendQLen = mathext.Max(sendQLen, len(si.SendQBuf))
// lastRecvLen = mathext.Max(lastRecvLen, len(si.LastRecv))
// lastSendLen = mathext.Max(lastSendLen, len(si.LastSend))
// }
// res := make([]string, 0)
// delim := " "
// for _, si := range info {
// line := make([]string, 0)
// line = append(line, fmt.Sprintf("%-"+fmt.Sprintf("%d", idLen)+"s", si.ID))
// line = append(line, fmt.Sprintf("%-"+fmt.Sprintf("%d", protocolLen)+"s", si.Protocol))
// line = append(line, fmt.Sprintf("%-"+fmt.Sprintf("%d", localAddrLen)+"s", si.LocalAddr))
// line = append(line, fmt.Sprintf("%-"+fmt.Sprintf("%d", remoteAddrLen)+"s", si.RemoteAddr))
// line = append(line, fmt.Sprintf("%-"+fmt.Sprintf("%d", stateLen)+"s", si.State))
// line = append(line, fmt.Sprintf("%-"+fmt.Sprintf("%d", recvQLen)+"s", si.RecvQBuf))
// line = append(line, fmt.Sprintf("%-"+fmt.Sprintf("%d", sendQLen)+"s", si.SendQBuf))
// line = append(line, fmt.Sprintf("%-"+fmt.Sprintf("%d", lastRecvLen)+"s", si.LastRecv))
// line = append(line, fmt.Sprintf("%-"+fmt.Sprintf("%d", lastSendLen)+"s", si.LastSend))
// res = append(res, strings.Join(line, delim))
// }
// return res
}

func (m *Mux) newEndpoints(old, new []UnderlayProperties) []UnderlayProperties {
Expand Down

0 comments on commit 2991cf1

Please sign in to comment.