general: fixed a bug which leads to panic when the specified interface not exists

This commit is contained in:
nadoo committed 2021-07-02 01:06:11 +08:00
1 parent 72e57ab6e3
commit 7f85f664e3
11 files changed
+27 -39

No files matched your search

+1
View File
@@ -7,6 +7,7 @@ import (
)
var (
// ErrNotSupported indicates that the operation is not supported
ErrNotSupported = errors.New("not supported")
)
+3
View File
@@ -36,6 +36,9 @@ func NewDirect(intface string, dialTimeout, relayTimeout time.Duration) (*Direct
return nil, errors.New(err.Error() + ": " + intface)
}
d.iface = iface
if ips := d.IFaceIPs(); len(ips) > 0 {
d.ip = ips[0]
}
}
}
+3 -5
View File
@@ -139,7 +139,7 @@ func (s *Stream) tryReadv2(b []byte) (n int, err error) {
// in an ideal environment:
// if more than half of buffer has consumed, send read ack to peer
// based on round-trip time of ACK, continous flowing data
// based on round-trip time of ACK, continuous flowing data
// won't slow down because of waiting for ACK, as long as the
// consumer keeps on reading data
// s.numRead == n also notify window at the first read
@@ -156,9 +156,8 @@ func (s *Stream) tryReadv2(b []byte) (n int, err error) {
if notifyConsumed > 0 {
err := s.sendWindowUpdate(notifyConsumed)
return n, err
} else {
return n, nil
}
return n, nil
}
select {
@@ -433,9 +432,8 @@ func (s *Stream) Close() error {
_, err = s.sess.writeFrame(newFrame(byte(s.sess.config.Version), cmdFIN, s.id))
s.sess.streamClosed(s.id)
return err
} else {
return io.ErrClosedPipe
}
return io.ErrClosedPipe
}
// GetDieCh returns a readonly chan which can be readable
+1
View File
@@ -94,6 +94,7 @@ func (s *SmuxServer) Serve(c net.Conn) {
}
}
// ServeStream serves a smux stream.
func (s *SmuxServer) ServeStream(c *smux.Stream) {
if s.server != nil {
s.server.Serve(c)