mirror of
https://github.com/cmz0228/hysteria-dev.git
synced 2025-07-30 22:16:53 +00:00
hysteria 2 prototype first public release
This commit is contained in:
36
core/internal/protocol/http.go
Normal file
36
core/internal/protocol/http.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package protocol
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
const (
|
||||
URLHost = "hysteria"
|
||||
URLPath = "/auth"
|
||||
|
||||
HeaderAuth = "Hysteria-Auth"
|
||||
HeaderCCRX = "Hysteria-CC-RX"
|
||||
|
||||
StatusAuthOK = 233
|
||||
)
|
||||
|
||||
func AuthRequestDataFromHeader(h http.Header) (auth string, rx uint64) {
|
||||
auth = h.Get(HeaderAuth)
|
||||
rx, _ = strconv.ParseUint(h.Get(HeaderCCRX), 10, 64)
|
||||
return
|
||||
}
|
||||
|
||||
func AuthRequestDataToHeader(h http.Header, auth string, rx uint64) {
|
||||
h.Set(HeaderAuth, auth)
|
||||
h.Set(HeaderCCRX, strconv.FormatUint(rx, 10))
|
||||
}
|
||||
|
||||
func AuthResponseDataFromHeader(h http.Header) (rx uint64) {
|
||||
rx, _ = strconv.ParseUint(h.Get(HeaderCCRX), 10, 64)
|
||||
return
|
||||
}
|
||||
|
||||
func AuthResponseDataToHeader(h http.Header, rx uint64) {
|
||||
h.Set(HeaderCCRX, strconv.FormatUint(rx, 10))
|
||||
}
|
Reference in New Issue
Block a user