c1be3debfd
* 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
37 lines
938 B
Go
37 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)
|
|
}
|