Documentation ¶
Index ¶
- Constants
- func ConvBandwidth(bw interface{}) (uint64, error)
- func Merge(a, b []byte) []byte
- func PrintQR(str string)
- func ReadLength(header []byte) int
- func SplitRead(stream io.Reader, expectLen int, packet []byte) (int, error)
- func StringToBps(s string) (uint64, error)
- func WriteLength(header []byte, length int)
- type GeoIPLoader
- type UpdateChecker
- type UpdateResponse
Constants ¶
const ( Byte = 1.0 << (10 * iota) Kilobyte Megabyte Gigabyte Terabyte )
Variables ¶
This section is empty.
Functions ¶
func ConvBandwidth ¶
ConvBandwidth handles both string and int types for bandwidth. When using string, it will be parsed as a bandwidth string with units. When using int, it will be parsed as a raw bandwidth in bytes per second. It does NOT support float types.
func StringToBps ¶
StringToBps converts a string to a bandwidth value in bytes per second. E.g. "100 Mbps", "512 kbps", "1g" are all valid.
func WriteLength ¶
Types ¶
type GeoIPLoader ¶
type GeoIPLoader struct { Filename string DownloadFunc func(filename, url string) // Called when downloading the GeoIP database. DownloadErrFunc func(err error) // Called when downloading the GeoIP database succeeds/fails. // contains filtered or unexported fields }
GeoIPLoader provides the on-demand GeoIP database loading function required by the ACL engine.
func (*GeoIPLoader) Load ¶
func (l *GeoIPLoader) Load() *geoip2.Reader
type UpdateChecker ¶
type UpdateChecker struct { CurrentVersion string Platform string Architecture string Channel string Side string Client *http.Client }
func NewClientUpdateChecker ¶
func NewClientUpdateChecker(currentVersion, platform, architecture, channel string, hyClient client.Client) *UpdateChecker
NewClientUpdateChecker ensures that update checks are routed through a HyClient, not being sent directly. This safeguard is CRITICAL, especially in scenarios where users use Hysteria to bypass censorship. Making direct HTTPS requests to the API endpoint could be easily spotted by censors (through SNI, for example), and could serve as a signal to identify and penalize Hysteria users.
func NewServerUpdateChecker ¶
func NewServerUpdateChecker(currentVersion, platform, architecture, channel string) *UpdateChecker
func (*UpdateChecker) Check ¶
func (uc *UpdateChecker) Check() (*UpdateResponse, error)