mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2024-11-15 13:41:23 +08:00
33a6579a3a
* Refactor ssr stream cipher to expose iv and key References: https://github.com/Dreamacro/go-shadowsocks2 https://github.com/sh4d0wfiend/go-shadowsocksr2 * Implement ssr obfs Reference: https://github.com/mzz2017/shadowsocksR * Implement ssr protocol References: https://github.com/mzz2017/shadowsocksR https://github.com/shadowsocksRb/shadowsocksr-libev https://github.com/shadowsocksr-backup/shadowsocksr
38 lines
938 B
Go
38 lines
938 B
Go
package obfs
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
var (
|
|
errTLS12TicketAuthIncorrectMagicNumber = errors.New("tls1.2_ticket_auth incorrect magic number")
|
|
errTLS12TicketAuthTooShortData = errors.New("tls1.2_ticket_auth too short data")
|
|
errTLS12TicketAuthHMACError = errors.New("tls1.2_ticket_auth hmac verifying failed")
|
|
)
|
|
|
|
// Obfs provides methods for decoding and encoding
|
|
type Obfs interface {
|
|
initForConn() Obfs
|
|
GetObfsOverhead() int
|
|
Decode(b []byte) ([]byte, bool, error)
|
|
Encode(b []byte) ([]byte, error)
|
|
}
|
|
|
|
type obfsCreator func(b *Base) Obfs
|
|
|
|
var obfsList = make(map[string]obfsCreator)
|
|
|
|
func register(name string, c obfsCreator) {
|
|
obfsList[name] = c
|
|
}
|
|
|
|
// PickObfs returns an obfs of the given name
|
|
func PickObfs(name string, b *Base) (Obfs, error) {
|
|
if obfsCreator, ok := obfsList[strings.ToLower(name)]; ok {
|
|
return obfsCreator(b), nil
|
|
}
|
|
return nil, fmt.Errorf("Obfs %s not supported", name)
|
|
}
|