Clash.Meta/constant/adapters.go

59 lines
817 B
Go
Raw Normal View History

2018-06-10 22:50:03 +08:00
package constant
import (
2018-06-14 01:00:58 +08:00
"net"
2018-06-10 22:50:03 +08:00
)
// Adapter Type
const (
Direct AdapterType = iota
2018-09-26 00:34:15 +08:00
Fallback
Reject
Selector
Shadowsocks
2018-08-12 13:50:54 +08:00
Socks5
Http
URLTest
2018-09-06 10:53:29 +08:00
Vmess
)
2018-06-10 22:50:03 +08:00
type ServerAdapter interface {
2018-09-30 12:25:52 +08:00
Metadata() *Metadata
2018-06-14 01:00:58 +08:00
Close()
2018-06-10 22:50:03 +08:00
}
type Proxy interface {
2018-06-16 21:34:13 +08:00
Name() string
Type() AdapterType
2018-12-22 23:56:42 +08:00
Generator(metadata *Metadata) (net.Conn, error)
2018-11-21 13:47:46 +08:00
MarshalJSON() ([]byte, error)
2018-06-10 22:50:03 +08:00
}
// AdapterType is enum of adapter type
type AdapterType int
func (at AdapterType) String() string {
switch at {
case Direct:
return "Direct"
2018-09-26 00:34:15 +08:00
case Fallback:
return "Fallback"
case Reject:
return "Reject"
case Selector:
return "Selector"
case Shadowsocks:
return "Shadowsocks"
2018-08-12 13:50:54 +08:00
case Socks5:
return "Socks5"
case Http:
return "Http"
case URLTest:
return "URLTest"
2018-09-06 10:53:29 +08:00
case Vmess:
return "Vmess"
default:
return "Unknow"
}
}