Fix caps settings

Force Bandwidth (should make configurable)
This commit is contained in:
Bolke de Bruin 2020-07-23 12:54:21 +02:00
parent e714881e59
commit 27d36f83f2
3 changed files with 22 additions and 9 deletions

View file

@ -171,5 +171,8 @@ func (c *Config) HandleDownload(w http.ResponseWriter, r *http.Request) {
"gatewaycredentialssource:i:5\r\n"+ "gatewaycredentialssource:i:5\r\n"+
"gatewayusagemethod:i:1\r\n"+ "gatewayusagemethod:i:1\r\n"+
"gatewayprofileusagemethod:i:1\r\n"+ "gatewayprofileusagemethod:i:1\r\n"+
"gatewayaccesstoken:s:"+token+"\r\n")) "gatewayaccesstoken:s:"+token+"\r\n"+
"networkautodetect:i:0\r\n"+
"bandwidthautodetect:i:1\r\n"+
"connection type:i:6\r\n"))
} }

View file

@ -69,6 +69,8 @@ func NewHandler(s *SessionInfo, conf *HandlerConf) *Handler {
return h return h
} }
const tunnelId = 10
func (h *Handler) Process() error { func (h *Handler) Process() error {
for { for {
pt, sz, pkt, err := h.ReadMessage() pt, sz, pkt, err := h.ReadMessage()
@ -295,9 +297,9 @@ func createTunnelResponse() []byte {
binary.Write(buf, binary.LittleEndian, uint16(0)) // reserved binary.Write(buf, binary.LittleEndian, uint16(0)) // reserved
// tunnel id (when is it used?) // tunnel id (when is it used?)
binary.Write(buf, binary.LittleEndian, uint32(10)) binary.Write(buf, binary.LittleEndian, uint32(tunnelId))
// caps, w2019 sends 63 -> windows client requests 63
binary.Write(buf, binary.LittleEndian, uint32(63)) binary.Write(buf, binary.LittleEndian, uint32(HTTP_CAPABILITY_IDLE_TIMEOUT))
return createPacket(PKT_TYPE_TUNNEL_RESPONSE, buf.Bytes()) return createPacket(PKT_TYPE_TUNNEL_RESPONSE, buf.Bytes())
} }
@ -358,8 +360,7 @@ func createChannelCreateResponse() []byte {
buf := new(bytes.Buffer) buf := new(bytes.Buffer)
binary.Write(buf, binary.LittleEndian, uint32(0)) // error code binary.Write(buf, binary.LittleEndian, uint32(0)) // error code
//binary.Write(buf, binary.LittleEndian, uint16(HTTP_CHANNEL_RESPONSE_FIELD_CHANNELID | HTTP_CHANNEL_RESPONSE_FIELD_AUTHNCOOKIE | HTTP_CHANNEL_RESPONSE_FIELD_UDPPORT)) // fields present binary.Write(buf, binary.LittleEndian, uint16(HTTP_CHANNEL_RESPONSE_FIELD_CHANNELID)) // fields present
binary.Write(buf, binary.LittleEndian, uint16(HTTP_CHANNEL_RESPONSE_FIELD_CHANNELID))
binary.Write(buf, binary.LittleEndian, uint16(0)) // reserved binary.Write(buf, binary.LittleEndian, uint16(0)) // reserved
// channel id is required for Windows clients // channel id is required for Windows clients

View file

@ -67,3 +67,12 @@ const (
SERVER_STATE_OPENED = 0x5 SERVER_STATE_OPENED = 0x5
SERVER_STATE_CLOSED = 0x6 SERVER_STATE_CLOSED = 0x6
) )
const (
HTTP_CAPABILITY_TYPE_QUAR_SOH = 0x1
HTTP_CAPABILITY_IDLE_TIMEOUT = 0x2
HTTP_CAPABILITY_MESSAGING_CONSENT_SIGN = 0x4
HTTP_CAPABILITY_MESSAGING_SERVICE_MSG = 0x8
HTTP_CAPABILITY_REAUTH = 0x10
HTTP_CAPABILITY_UDP_TRANSPORT = 0x20
)