Clash.Meta/adapters/outbound/reject.go

55 lines
1.1 KiB
Go
Raw Normal View History

2018-06-10 22:50:03 +08:00
package adapters
import (
"io"
2018-06-14 01:00:58 +08:00
"net"
2018-07-31 17:53:39 +08:00
"time"
2018-06-10 22:50:03 +08:00
C "github.com/Dreamacro/clash/constant"
)
type Reject struct {
2018-12-22 23:56:42 +08:00
*Base
2018-06-10 22:50:03 +08:00
}
2019-03-03 11:59:07 +08:00
func (r *Reject) Dial(metadata *C.Metadata) (net.Conn, error) {
2018-12-22 23:56:42 +08:00
return &NopConn{}, nil
2018-11-21 13:47:46 +08:00
}
2018-06-10 22:50:03 +08:00
func NewReject() *Reject {
2018-12-22 23:56:42 +08:00
return &Reject{
Base: &Base{
name: "REJECT",
tp: C.Reject,
},
}
2018-06-10 22:50:03 +08:00
}
2018-07-31 17:53:39 +08:00
type NopConn struct{}
2018-06-10 22:50:03 +08:00
2018-07-31 17:53:39 +08:00
func (rw *NopConn) Read(b []byte) (int, error) {
return 0, io.EOF
2018-06-10 22:50:03 +08:00
}
2018-07-31 17:53:39 +08:00
func (rw *NopConn) Write(b []byte) (int, error) {
2018-06-10 22:50:03 +08:00
return 0, io.EOF
}
2018-07-31 17:53:39 +08:00
// Close is fake function for net.Conn
func (rw *NopConn) Close() error { return nil }
// LocalAddr is fake function for net.Conn
func (rw *NopConn) LocalAddr() net.Addr { return nil }
// RemoteAddr is fake function for net.Conn
func (rw *NopConn) RemoteAddr() net.Addr { return nil }
// SetDeadline is fake function for net.Conn
func (rw *NopConn) SetDeadline(time.Time) error { return nil }
// SetReadDeadline is fake function for net.Conn
func (rw *NopConn) SetReadDeadline(time.Time) error { return nil }
// SetWriteDeadline is fake function for net.Conn
func (rw *NopConn) SetWriteDeadline(time.Time) error { return nil }