mirror of
https://github.com/cmz0228/hysteria-dev.git
synced 2025-09-19 06:26:00 +00:00
feat(wip): udp rework server side
This commit is contained in:
@@ -9,31 +9,34 @@ const (
|
||||
URLHost = "hysteria"
|
||||
URLPath = "/auth"
|
||||
|
||||
HeaderAuth = "Hysteria-Auth"
|
||||
HeaderCCRX = "Hysteria-CC-RX"
|
||||
HeaderPadding = "Hysteria-Padding"
|
||||
RequestHeaderAuth = "Hysteria-Auth"
|
||||
ResponseHeaderUDPEnabled = "Hysteria-UDP"
|
||||
CommonHeaderCCRX = "Hysteria-CC-RX"
|
||||
CommonHeaderPadding = "Hysteria-Padding"
|
||||
|
||||
StatusAuthOK = 233
|
||||
)
|
||||
|
||||
func AuthRequestDataFromHeader(h http.Header) (auth string, rx uint64) {
|
||||
auth = h.Get(HeaderAuth)
|
||||
rx, _ = strconv.ParseUint(h.Get(HeaderCCRX), 10, 64)
|
||||
auth = h.Get(RequestHeaderAuth)
|
||||
rx, _ = strconv.ParseUint(h.Get(CommonHeaderCCRX), 10, 64)
|
||||
return
|
||||
}
|
||||
|
||||
func AuthRequestDataToHeader(h http.Header, auth string, rx uint64) {
|
||||
h.Set(HeaderAuth, auth)
|
||||
h.Set(HeaderCCRX, strconv.FormatUint(rx, 10))
|
||||
h.Set(HeaderPadding, authRequestPadding.String())
|
||||
h.Set(RequestHeaderAuth, auth)
|
||||
h.Set(CommonHeaderCCRX, strconv.FormatUint(rx, 10))
|
||||
h.Set(CommonHeaderPadding, authRequestPadding.String())
|
||||
}
|
||||
|
||||
func AuthResponseDataFromHeader(h http.Header) (rx uint64) {
|
||||
rx, _ = strconv.ParseUint(h.Get(HeaderCCRX), 10, 64)
|
||||
func AuthResponseDataFromHeader(h http.Header) (udp bool, rx uint64) {
|
||||
udp, _ = strconv.ParseBool(h.Get(ResponseHeaderUDPEnabled))
|
||||
rx, _ = strconv.ParseUint(h.Get(CommonHeaderCCRX), 10, 64)
|
||||
return
|
||||
}
|
||||
|
||||
func AuthResponseDataToHeader(h http.Header, rx uint64) {
|
||||
h.Set(HeaderCCRX, strconv.FormatUint(rx, 10))
|
||||
h.Set(HeaderPadding, authResponsePadding.String())
|
||||
func AuthResponseDataToHeader(h http.Header, udp bool, rx uint64) {
|
||||
h.Set(ResponseHeaderUDPEnabled, strconv.FormatBool(udp))
|
||||
h.Set(CommonHeaderCCRX, strconv.FormatUint(rx, 10))
|
||||
h.Set(CommonHeaderPadding, authResponsePadding.String())
|
||||
}
|
||||
|
Reference in New Issue
Block a user