From 27d36f83f2d5142aeff93d4c6736715022433e2e Mon Sep 17 00:00:00 2001 From: Bolke de Bruin <bolke@xs4all.nl> Date: Thu, 23 Jul 2020 12:54:21 +0200 Subject: [PATCH] Fix caps settings Force Bandwidth (should make configurable) --- api/web.go | 5 ++++- protocol/handler.go | 15 ++++++++------- protocol/types.go | 11 ++++++++++- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/api/web.go b/api/web.go index 1d00c43..181a2ae 100644 --- a/api/web.go +++ b/api/web.go @@ -171,5 +171,8 @@ func (c *Config) HandleDownload(w http.ResponseWriter, r *http.Request) { "gatewaycredentialssource:i:5\r\n"+ "gatewayusagemethod: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")) } diff --git a/protocol/handler.go b/protocol/handler.go index 0af7b95..4437b3a 100644 --- a/protocol/handler.go +++ b/protocol/handler.go @@ -69,6 +69,8 @@ func NewHandler(s *SessionInfo, conf *HandlerConf) *Handler { return h } +const tunnelId = 10 + func (h *Handler) Process() error { for { pt, sz, pkt, err := h.ReadMessage() @@ -295,9 +297,9 @@ func createTunnelResponse() []byte { binary.Write(buf, binary.LittleEndian, uint16(0)) // reserved // tunnel id (when is it used?) - binary.Write(buf, binary.LittleEndian, uint32(10)) - // caps, w2019 sends 63 -> windows client requests 63 - binary.Write(buf, binary.LittleEndian, uint32(63)) + binary.Write(buf, binary.LittleEndian, uint32(tunnelId)) + + binary.Write(buf, binary.LittleEndian, uint32(HTTP_CAPABILITY_IDLE_TIMEOUT)) return createPacket(PKT_TYPE_TUNNEL_RESPONSE, buf.Bytes()) } @@ -357,10 +359,9 @@ func readChannelCreateRequest(data []byte) (server string, port uint16) { func createChannelCreateResponse() []byte { buf := new(bytes.Buffer) - 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)) - binary.Write(buf, binary.LittleEndian, uint16(0)) // reserved + binary.Write(buf, binary.LittleEndian, uint32(0)) // error code + binary.Write(buf, binary.LittleEndian, uint16(HTTP_CHANNEL_RESPONSE_FIELD_CHANNELID)) // fields present + binary.Write(buf, binary.LittleEndian, uint16(0)) // reserved // channel id is required for Windows clients binary.Write(buf, binary.LittleEndian, uint32(1)) // channel id diff --git a/protocol/types.go b/protocol/types.go index a8e788d..e3473f3 100644 --- a/protocol/types.go +++ b/protocol/types.go @@ -65,5 +65,14 @@ const ( SERVER_STATE_TUNNEL_AUTHORIZE = 0x3 SERVER_STATE_CHANNEL_CREATE = 0x4 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 ) -- GitLab