diff --git a/api/web.go b/api/web.go index 1d00c43e497e2ae070503164432f3ab21a4bfbea..181a2ae880f77948adc2dfbd1f65d7fd8af19a1f 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 0af7b95020df0cb50ca29274bf8298b08ed3054e..4437b3a15f50bdb8d45013de728047c3d03f6328 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 a8e788ddfc13411a01a725d63c71e0d847418ec5..e3473f35c56fc54faf3bea17a924e616448dee56 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 )