mirror of
https://github.com/nadoo/glider.git
synced 2026-11-19 07:09:42 +08:00
ssh: try to fix #299
This commit is contained in:
1 parent
346db3338e
commit
638adc63d6
4 files changed
+19
-19
No files matched your search
@@ -50,6 +50,9 @@ func (s *SmuxClient) Addr() string {
|
||||
|
||||
// Dial connects to the address addr on the network net via the proxy.
|
||||
func (s *SmuxClient) Dial(network, addr string) (net.Conn, error) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
if s.session != nil {
|
||||
if c, err := s.session.OpenStream(); err == nil {
|
||||
return c, err
|
||||
@@ -68,9 +71,6 @@ func (s *SmuxClient) DialUDP(network, addr string) (net.PacketConn, net.Addr, er
|
||||
}
|
||||
|
||||
func (s *SmuxClient) initConn() error {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
conn, err := s.dialer.Dial("tcp", s.addr)
|
||||
if err != nil {
|
||||
log.F("[smux] dial to %s error: %s", s.addr, err)
|
||||
|
||||
+4
-4
@@ -34,7 +34,7 @@ func init() {
|
||||
func NewSSH(s string, d proxy.Dialer, p proxy.Proxy) (*SSH, error) {
|
||||
u, err := url.Parse(s)
|
||||
if err != nil {
|
||||
log.F("parse err: %s", err)
|
||||
log.F("[ssh] parse err: %s", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -92,9 +92,6 @@ func (s *SSH) Addr() string {
|
||||
}
|
||||
|
||||
func (s *SSH) initConn() error {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
c, err := s.dialer.Dial("tcp", s.addr)
|
||||
if err != nil {
|
||||
log.F("[ssh]: dial to %s error: %s", s.addr, err)
|
||||
@@ -112,6 +109,9 @@ func (s *SSH) initConn() error {
|
||||
|
||||
// Dial connects to the address addr on the network net via the proxy.
|
||||
func (s *SSH) Dial(network, addr string) (net.Conn, error) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
if c, err := ssh.NewClient(s.sshConn, s.sshChan, s.sshReq).Dial(network, addr); err == nil {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user