2018-06-10 22:50:03 +08:00
|
|
|
package constant
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
2018-06-14 01:00:58 +08:00
|
|
|
"net"
|
2018-06-10 22:50:03 +08:00
|
|
|
)
|
|
|
|
|
2018-07-12 23:28:38 +08:00
|
|
|
// Adapter Type
|
|
|
|
const (
|
|
|
|
Direct AdapterType = iota
|
|
|
|
Reject
|
|
|
|
Selector
|
|
|
|
Shadowsocks
|
|
|
|
URLTest
|
|
|
|
)
|
|
|
|
|
2018-06-10 22:50:03 +08:00
|
|
|
type ProxyAdapter interface {
|
2018-06-14 01:00:58 +08:00
|
|
|
ReadWriter() io.ReadWriter
|
|
|
|
Conn() net.Conn
|
2018-06-10 22:50:03 +08:00
|
|
|
Close()
|
|
|
|
}
|
|
|
|
|
|
|
|
type ServerAdapter interface {
|
|
|
|
Addr() *Addr
|
2018-06-14 01:00:58 +08:00
|
|
|
Connect(ProxyAdapter)
|
|
|
|
Close()
|
2018-06-10 22:50:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type Proxy interface {
|
2018-06-16 21:34:13 +08:00
|
|
|
Name() string
|
2018-07-12 23:28:38 +08:00
|
|
|
Type() AdapterType
|
2018-06-10 22:50:03 +08:00
|
|
|
Generator(addr *Addr) (ProxyAdapter, error)
|
|
|
|
}
|
2018-07-12 23:28:38 +08:00
|
|
|
|
|
|
|
// AdapterType is enum of adapter type
|
|
|
|
type AdapterType int
|
|
|
|
|
|
|
|
func (at AdapterType) String() string {
|
|
|
|
switch at {
|
|
|
|
case Direct:
|
|
|
|
return "Direct"
|
|
|
|
case Reject:
|
|
|
|
return "Reject"
|
|
|
|
case Selector:
|
|
|
|
return "Selector"
|
|
|
|
case Shadowsocks:
|
|
|
|
return "Shadowsocks"
|
|
|
|
case URLTest:
|
|
|
|
return "URLTest"
|
|
|
|
default:
|
|
|
|
return "Unknow"
|
|
|
|
}
|
|
|
|
}
|