mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-05-08 14:13:22 +00:00
30 lines
654 B
Go
30 lines
654 B
Go
package conf
|
|
|
|
import (
|
|
"github.com/xtls/xray-core/common/errors"
|
|
"github.com/xtls/xray-core/common/protocol"
|
|
"github.com/xtls/xray-core/proxy/hysteria"
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
type HysteriaClientConfig struct {
|
|
Version int32 `json:"version"`
|
|
Address *Address `json:"address"`
|
|
Port uint16 `json:"port"`
|
|
}
|
|
|
|
func (c *HysteriaClientConfig) Build() (proto.Message, error) {
|
|
if c.Version != 2 {
|
|
return nil, errors.New("version != 2")
|
|
}
|
|
|
|
config := &hysteria.ClientConfig{}
|
|
config.Version = c.Version
|
|
config.Server = &protocol.ServerEndpoint{
|
|
Address: c.Address.Build(),
|
|
Port: uint32(c.Port),
|
|
}
|
|
|
|
return config, nil
|
|
}
|