github.com/yaling888/clash@v1.53.0/transport/header/header.go (about) 1 package header 2 3 import ( 4 "fmt" 5 "strings" 6 7 "github.com/yaling888/clash/transport/header/dtls" 8 "github.com/yaling888/clash/transport/header/srtp" 9 "github.com/yaling888/clash/transport/header/utp" 10 "github.com/yaling888/clash/transport/header/wechat" 11 "github.com/yaling888/clash/transport/header/wireguard" 12 ) 13 14 type Header interface { 15 Size() int 16 Fill(b []byte) 17 } 18 19 // New supports name "none" | "srtp" | "utp" | "dtls" | "wechat-video" | "wireguard", 20 // returns "nil, nil" if name is "none" 21 func New(name string) (Header, error) { 22 switch strings.ToLower(name) { 23 case "", "none": 24 return nil, nil 25 case "srtp": 26 return srtp.New(), nil 27 case "utp": 28 return utp.New(), nil 29 case "dtls": 30 return dtls.New(), nil 31 case "wechat-video": 32 return wechat.New(), nil 33 case "wireguard": 34 return wireguard.New(), nil 35 default: 36 return nil, fmt.Errorf("unsupported obfs: %s", name) 37 } 38 }