2018-06-10 14:50:03 +00:00
|
|
|
package adapters
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
2018-06-13 17:00:58 +00:00
|
|
|
"net"
|
2018-06-10 14:50:03 +00:00
|
|
|
|
|
|
|
C "github.com/Dreamacro/clash/constant"
|
|
|
|
)
|
|
|
|
|
|
|
|
// RejectAdapter is a reject connected adapter
|
|
|
|
type RejectAdapter struct {
|
|
|
|
}
|
|
|
|
|
2018-06-13 17:00:58 +00:00
|
|
|
// Close is used to close connection
|
|
|
|
func (r *RejectAdapter) Close() {}
|
2018-06-10 14:50:03 +00:00
|
|
|
|
2018-06-17 14:41:32 +00:00
|
|
|
// Conn is used to http request
|
2018-06-13 17:00:58 +00:00
|
|
|
func (r *RejectAdapter) Conn() net.Conn {
|
|
|
|
return nil
|
2018-06-10 14:50:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Reject struct {
|
|
|
|
}
|
|
|
|
|
2018-06-16 13:34:13 +00:00
|
|
|
func (r *Reject) Name() string {
|
|
|
|
return "Reject"
|
|
|
|
}
|
|
|
|
|
2018-07-12 15:28:38 +00:00
|
|
|
func (r *Reject) Type() C.AdapterType {
|
|
|
|
return C.Reject
|
|
|
|
}
|
|
|
|
|
2018-06-10 14:50:03 +00:00
|
|
|
func (r *Reject) Generator(addr *C.Addr) (adapter C.ProxyAdapter, err error) {
|
|
|
|
return &RejectAdapter{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewReject() *Reject {
|
|
|
|
return &Reject{}
|
|
|
|
}
|
|
|
|
|
|
|
|
type NopRW struct{}
|
|
|
|
|
|
|
|
func (rw *NopRW) Read(b []byte) (int, error) {
|
|
|
|
return len(b), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (rw *NopRW) Write(b []byte) (int, error) {
|
|
|
|
return 0, io.EOF
|
|
|
|
}
|