1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 18:17:52 -05:00
v2fly/transport/internet/header.go
2017-01-12 22:47:10 +01:00

27 lines
461 B
Go

package internet
import (
"context"
"errors"
"v2ray.com/core/common"
)
type PacketHeader interface {
Size() int
Write([]byte) (int, error)
}
func CreatePacketHeader(config interface{}) (PacketHeader, error) {
header, err := common.CreateObject(context.Background(), config)
if err != nil {
return nil, err
}
switch h := header.(type) {
case PacketHeader:
return h, nil
default:
return nil, errors.New("Internet: Not a packet header.")
}
}