2018-06-10 14:50:03 +00:00
|
|
|
package constant
|
|
|
|
|
|
|
|
import (
|
2018-06-13 17:00:58 +00:00
|
|
|
"net"
|
2018-06-10 14:50:03 +00:00
|
|
|
)
|
|
|
|
|
2018-07-12 15:28:38 +00:00
|
|
|
// Adapter Type
|
|
|
|
const (
|
|
|
|
Direct AdapterType = iota
|
2018-09-25 16:34:15 +00:00
|
|
|
Fallback
|
2018-07-12 15:28:38 +00:00
|
|
|
Reject
|
|
|
|
Selector
|
|
|
|
Shadowsocks
|
2018-08-12 05:50:54 +00:00
|
|
|
Socks5
|
2018-12-03 15:27:00 +00:00
|
|
|
Http
|
2018-07-12 15:28:38 +00:00
|
|
|
URLTest
|
2018-09-06 02:53:29 +00:00
|
|
|
Vmess
|
2019-02-15 06:25:20 +00:00
|
|
|
LoadBalance
|
2018-07-12 15:28:38 +00:00
|
|
|
)
|
|
|
|
|
2018-06-10 14:50:03 +00:00
|
|
|
type ServerAdapter interface {
|
2018-09-30 04:25:52 +00:00
|
|
|
Metadata() *Metadata
|
2018-06-13 17:00:58 +00:00
|
|
|
Close()
|
2018-06-10 14:50:03 +00:00
|
|
|
}
|
|
|
|
|
2019-03-15 16:43:16 +00:00
|
|
|
type ProxyAdapter interface {
|
2018-06-16 13:34:13 +00:00
|
|
|
Name() string
|
2018-07-12 15:28:38 +00:00
|
|
|
Type() AdapterType
|
2019-03-03 03:59:07 +00:00
|
|
|
Dial(metadata *Metadata) (net.Conn, error)
|
2019-03-15 16:43:16 +00:00
|
|
|
Destroy()
|
2018-11-21 05:47:46 +00:00
|
|
|
MarshalJSON() ([]byte, error)
|
2018-06-10 14:50:03 +00:00
|
|
|
}
|
2018-07-12 15:28:38 +00:00
|
|
|
|
2019-03-15 16:43:16 +00:00
|
|
|
type Proxy interface {
|
|
|
|
ProxyAdapter
|
|
|
|
Alive() bool
|
|
|
|
URLTest(url string) (int16, error)
|
|
|
|
}
|
|
|
|
|
2018-07-12 15:28:38 +00:00
|
|
|
// AdapterType is enum of adapter type
|
|
|
|
type AdapterType int
|
|
|
|
|
|
|
|
func (at AdapterType) String() string {
|
|
|
|
switch at {
|
|
|
|
case Direct:
|
|
|
|
return "Direct"
|
2018-09-25 16:34:15 +00:00
|
|
|
case Fallback:
|
|
|
|
return "Fallback"
|
2018-07-12 15:28:38 +00:00
|
|
|
case Reject:
|
|
|
|
return "Reject"
|
|
|
|
case Selector:
|
|
|
|
return "Selector"
|
|
|
|
case Shadowsocks:
|
|
|
|
return "Shadowsocks"
|
2018-08-12 05:50:54 +00:00
|
|
|
case Socks5:
|
|
|
|
return "Socks5"
|
2018-12-03 15:27:00 +00:00
|
|
|
case Http:
|
|
|
|
return "Http"
|
2018-07-12 15:28:38 +00:00
|
|
|
case URLTest:
|
|
|
|
return "URLTest"
|
2018-09-06 02:53:29 +00:00
|
|
|
case Vmess:
|
|
|
|
return "Vmess"
|
2019-02-15 06:25:20 +00:00
|
|
|
case LoadBalance:
|
|
|
|
return "LoadBalance"
|
2018-07-12 15:28:38 +00:00
|
|
|
default:
|
|
|
|
return "Unknow"
|
|
|
|
}
|
|
|
|
}
|