mirror of
https://github.com/injoyai/tdx.git
synced 2025-11-26 21:25:35 +08:00
整理代码
This commit is contained in:
15
client.go
15
client.go
@@ -8,11 +8,9 @@ import (
|
|||||||
"github.com/injoyai/conv"
|
"github.com/injoyai/conv"
|
||||||
"github.com/injoyai/ios"
|
"github.com/injoyai/ios"
|
||||||
"github.com/injoyai/ios/client"
|
"github.com/injoyai/ios/client"
|
||||||
"github.com/injoyai/ios/module/tcp"
|
|
||||||
"github.com/injoyai/logs"
|
"github.com/injoyai/logs"
|
||||||
"github.com/injoyai/tdx/protocol"
|
"github.com/injoyai/tdx/protocol"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"strings"
|
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -31,19 +29,16 @@ func WithRedial(b ...bool) client.Option {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dial 与服务器建立连接
|
|
||||||
func Dial(addr string, op ...client.Option) (cli *Client, err error) {
|
|
||||||
if !strings.Contains(addr, ":") {
|
|
||||||
addr += ":7709"
|
|
||||||
}
|
|
||||||
return DialWith(tcp.NewDial(addr), op...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// DialDefault 默认连接方式
|
// DialDefault 默认连接方式
|
||||||
func DialDefault(op ...client.Option) (cli *Client, err error) {
|
func DialDefault(op ...client.Option) (cli *Client, err error) {
|
||||||
return DialHostsRange(Hosts, op...)
|
return DialHostsRange(Hosts, op...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Dial 与服务器建立连接
|
||||||
|
func Dial(addr string, op ...client.Option) (cli *Client, err error) {
|
||||||
|
return DialWith(NewTCPDial(addr), op...)
|
||||||
|
}
|
||||||
|
|
||||||
// DialHosts 与服务器建立连接,多个服务器轮询,开启重试生效
|
// DialHosts 与服务器建立连接,多个服务器轮询,开启重试生效
|
||||||
func DialHosts(hosts []string, op ...client.Option) (cli *Client, err error) {
|
func DialHosts(hosts []string, op ...client.Option) (cli *Client, err error) {
|
||||||
return DialWith(NewHostDial(hosts), op...)
|
return DialWith(NewHostDial(hosts), op...)
|
||||||
|
|||||||
Reference in New Issue
Block a user